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-checkbox-group {{className ? className : ''}} ant-checkbox-group-{{position}}"
style="{{style}}"
>
<checkbox-group
name="{{name}}"
value="{{mixin.value}}"
>
<view class="ant-checkbox-group-body">
<block a:if="{{position === 'vertical'}}">
<block
a:for="{{options}}"
a:for-index="index"
a:for-item="item"
>
<list-item>
<ant-checkbox
color="{{color}}"
checked="{{componentUtils.getCheckboxChecked(item, mixin.value)}}"
data-index="{{index}}"
value="{{item.value}}"
disabled="{{disabled || item.disabled}}"
onChange="onChange"
>
<slot
name="label"
value="{{item}}"
index="{{index}}"
>
<view class="ant-checkbox-group-item-label-default">
{{item.label}}
</view>
</slot>
</ant-checkbox>
</list-item>
</block>
</block>
<block a:else>
<block
a:for="{{options}}"
a:for-index="index"
a:for-item="item"
>
<ant-checkbox
color="{{color}}"
checked="{{componentUtils.getCheckboxChecked(item, mixin.value)}}"
data-index="{{index}}"
value="{{item.value}}"
disabled="{{disabled || item.disabled}}"
onChange="onChange"
>
<slot
name="label"
value="{{item}}"
index="{{index}}"
>
<view class="ant-checkbox-group-item-label-default">
{{item.label}}
</view>
</slot>
</ant-checkbox>
</block>
</block>
</view>
</checkbox-group>
</list>

View File

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

View File

@ -0,0 +1,36 @@
import { __spreadArray } from "tslib";
import { Component, triggerEvent, getValueFromProps } from '../../_util/simply';
import { CheckboxGroupDefaultProps } from './props';
import mixinValue from '../../mixins/value';
Component(CheckboxGroupDefaultProps, {
onChange: function (args, e) {
if (getValueFromProps(this, 'disabled')) {
return;
}
var event;
event = e;
var currentValue = this.getValue();
var index = event.currentTarget.dataset.index;
var selectValue = getValueFromProps(this, 'options')[index].value;
if (currentValue.indexOf(selectValue) > -1) {
currentValue = currentValue.filter(function (v) { return v !== selectValue; });
}
else {
currentValue = __spreadArray(__spreadArray([], currentValue, true), [selectValue], false);
}
if (!this.isControlled()) {
this.update(currentValue);
}
triggerEvent(this, 'change', currentValue, e);
},
}, null, [
mixinValue({
transformValue: function (val) {
var value = val || [];
return {
needUpdate: true,
value: value,
};
},
}),
]);

View File

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

View File

@ -0,0 +1,50 @@
@import (reference) '../variable.less';
@checkGroupPrefix: ant-checkbox-group;
.@{checkGroupPrefix} {
&-horizontal {
.@{checkGroupPrefix}-body {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.ant-list-item-line {
padding-right: 0;
}
.ant-checkbox-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: @checkbox-header-color;
}
&-body {
position: relative;
overflow: hidden;
.ant-checkbox-item-content {
.ant-checkbox-group-item-label-default:not(:nth-child(1)) {
display: none;
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,17 @@
import { CheckboxDefaultProps } from './props';
import { Component, triggerEvent } from '../_util/simply';
import mixinValue from '../mixins/value';
Component(CheckboxDefaultProps, {
onChange: function (e) {
var value = !this.getValue();
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,92 @@
@import (reference) './variable.less';
@checkboxItemPrefix: ant-checkbox-item;
.@{checkboxItemPrefix} {
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: @checkbox-size;
height: @checkbox-size;
flex: 0 0 @checkbox-size;
}
&-base {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
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: @checkbox-border-width solid @checkbox-border-color;
border-radius: @checkbox-corner-radius;
width: 100%;
height: 100%;
box-sizing: border-box;
}
&-checkedIcon {
border-radius: @checkbox-corner-radius;
background-color: @checkbox-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: @checkbox-border-width solid @checkbox-border-color;
border-radius: @checkbox-corner-radius;
width: 100%;
height: 100%;
background-color: @checkbox-disabled-background;
}
&-disabledCheckedIcon {
box-sizing: border-box;
border: @checkbox-border-width solid @checkbox-border-color;
background-color: @checkbox-disabled-background;
border-radius: @checkbox-corner-radius;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
&-icon {
color: @checkbox-border-color;
font-size: 28 * @rpx;
}
}
}
&-disabled {
opacity: @opacity-disabled;
}
}

View File

@ -0,0 +1,21 @@
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 getCheckboxChecked(item, value) {
return (value || []).indexOf(item.value) > -1;
}
export default {
getClassName: getClassName,
getCheckboxChecked: getCheckboxChecked
};

View File

@ -0,0 +1,13 @@
import { IBaseProps } from '../_util/base';
/**
* @description 复选框,表单组件。
*/
export interface ICheckboxProps extends IBaseProps {
value?: any;
checked: boolean;
defaultChecked?: boolean;
disabled: boolean;
color: string;
onChange?: (checked: boolean, e: any) => void;
}
export declare const CheckboxDefaultProps: Partial<ICheckboxProps>;

View File

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

View File

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