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 @@
.ant-selector{position:relative;display:flex;flex-direction:column;background-color:#fff;line-height:1.4}.ant-selector-disabled .ant-selector-content{opacity:.6}.ant-selector-disabled .ant-selector-content .ant-selector-item-disabled{opacity:1}.ant-selector-content{display:flex;flex:0 33.3333%;padding:calc(12px / 2);box-sizing:border-box}.ant-selector-content-item2{flex:1}.ant-selector-content-container{display:flex;flex-wrap:wrap;justify-content:flex-start}.ant-selector-content .ant-tap-modal-mask{width:calc(100% - 24 * .5px);height:calc(100% - 24 * .5px);margin:6px 0 0 6px}.ant-selector-item{position:relative;display:flex;flex:1;flex-direction:column;justify-content:flex-start;overflow:hidden;padding:calc(12px / 2) calc(12px / 4);text-align:center;background-color:#f5f5f5;border-radius:4px}.ant-selector-item-active{background-color:#e7f1ff}.ant-selector-item-active .ant-selector-item-text{color:#1677ff}.ant-selector-item-disabled{opacity:.6}.ant-selector-item-text{font-size:15px;color:#333}.ant-selector-item-subtext{font-size:13px;color:#999}.ant-selector-item-badge-active{position:absolute;top:0;left:0;right:0;bottom:0;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAfCAYAAAH8T49dAAAAAXNSR0IArs4c6QAAA7JJREFUWAnNV1tIlEEU/lYrzRClaHdd14jMlEwKBEGolwKhnqIICiKE6ikKhMRdk1ikwCx86KECoYKgsIuVUBT4FBQEUm9dpB4iKrSLouWau+7pnP2d/S/+e/fSPOxczne++ebM+WdngFSKs4XIhJMBKdFBl4/61MAspHJzqIbUjBrlqig2aHTLmUHQUIe0tBJDqgFr7fZRY4RwLS7QOIU4m4BrA+SeCOKbYpWpXT6tFwVavRVw7muZyaTNOoWSYgtyn6K6SBgvlVM0mKojNW/WWwWoLdMsJpDQ88ZWiUkA1w9poNh0av4aD3DnCBCaBmrOzoCqA7TsexB/ta79b4zJ3pzaaGmAvKEgPmdF5vTRUxAa1JRpk3He5HPeBBWBsU6ZjFV0sopmo7O1nZSMdyXMTrlWR9nCx8eA4XF9l5ZYQdLnxDjA+35T2eQTGJkAqtq1PFAk6rNQOJMyVwv95ENhpTIaa8mX/hNmJUa7tB2lrbSFE+q11bCofQ6N37TMTNUw0QDHuDZrMo7zJMc5T4RkTMbJW8zJO2JcjekoMBoStd1+2mUlEnzaZByfG5EIHtlNltYy+Wv4wiSccfYlJbJAgHIuBcHHW+KSdJneNqqIR/QhAPQe1SdISMbxaZoKYVCH6y0hKswHfA/1sbjLZKIXnIj1OlRvKaJtXcDgsD5uq4wTcUIRbS4F5NSoLtGc4hGJ1aSs8hwVjvzCmD6X1np/GiguAMYntaVZFSl8TJmrlXbYEQmwsh0Y5fNMYhSPSHBRZRyfbl4W/7tlVxwcn0/8oa7JjkbzNsVsLgiz4fB20fLQEK7y4vb/F8KcfqpHBL28KLda2KIJ23ebcp+9wnnOoSYlxlgvuDCPn6rCEfSxiAqjEGt7wYTxfb05AnTwxSf2+VrFGPvzKqwsQJ6pIO5zMtcZJ02lPS/C+P/roMMBOYP4uMqszJmwdS1U9Bu4xTJ2pirFUwRs3wA8eQP8+GP2ylqYx0cNYUIP0xabqeP35B7cc1g7/gX1/COwp9uMz0jY+ouUN/YVVziRG810iXtWQXJB38uCjH+5iiEtYSU+qp0mPGBnryJQtZ+fOuWrgQv9wLshNarV6QhSnkmFyR3q8iTOcCL7lZO1LlgKDPiAVSs0i7w6JBL5/E4xblmiCFk54wora6PyqTD6WNBGq1O8vrxc7vJdQO4ixpKOIOU3SxjfEI7zg7+L88f2XaYcE9WbWGDnboBPeJzkf0C7HErkL7aoMFeAnBTEPe5vTeawUPZ/WGpTpu45f4MAAAAASUVORK5CYII=) right bottom no-repeat;background-size:19px 15px}

View File

@ -0,0 +1,44 @@
<import-sjs
from="./index.sjs"
name="util"
></import-sjs>
<view
class="ant-selector {{className ? className : ''}} {{disabled ? 'ant-selector-disabled' : ''}}"
style="{{style}}"
>
<view class="ant-selector-content-container">
<block
a:for="{{options}}"
a:for-index="index"
a:for-item="item"
>
<view class="ant-selector-content {{options.length <= 2 ? 'ant-selector-content-item2' : ''}}">
<view
class="ant-selector-item {{item.disabled ? 'ant-selector-item-disabled' : ''}} {{util.getChecked(item.value, mixin.value, multiple) ? 'ant-selector-item-active ' + (activeItemClassName || '') : ''}}"
style="{{util.getChecked(item.value, mixin.value, multiple) ? activeItemStyle || '' : ''}}"
data-value="{{item.value}}"
data-disabled="{{item.disabled}}"
onTap="onChange"
>
<view
a:if="{{item.text}}"
class="ant-selector-item-text"
>
{{item.text}}
</view>
<view
a:if="{{item.subText}}"
class="ant-selector-item-subtext"
>
{{item.subText}}
</view>
<view
a:if="{{util.getChecked(item.value, mixin.value, multiple)}}"
class="ant-selector-item-badge-active"
></view>
<slot item="{{item}}"></slot>
</view>
</view>
</block>
</view>
</view>

View File

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

View File

@ -0,0 +1,63 @@
import { __spreadArray } from "tslib";
import { Component, triggerEventValues, getValueFromProps, } from '../_util/simply';
import { SelectorDefaultProps } from './props';
import mixinValue from '../mixins/value';
Component(SelectorDefaultProps, {
onChange: function (e) {
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value;
var _b = getValueFromProps(this, [
'multiple',
'options',
'maxSelectedCount',
'minSelectedCount',
'disabled',
]), multiple = _b[0], options = _b[1], maxSelectedCount = _b[2], minSelectedCount = _b[3], disabledFromProps = _b[4];
if (disabled || disabledFromProps) {
return;
}
if (multiple) {
var currentValue_1 = this.getValue() || [];
if (currentValue_1.indexOf(value) > -1) {
if (typeof minSelectedCount === 'number' &&
currentValue_1.length <= minSelectedCount) {
triggerEventValues(this, 'selectMin', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
currentValue_1 = currentValue_1.filter(function (v) { return v !== value; });
}
else {
if (typeof maxSelectedCount === 'number' &&
currentValue_1.length >= maxSelectedCount) {
triggerEventValues(this, 'selectMax', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
currentValue_1 = __spreadArray(__spreadArray([], currentValue_1, true), [value], false);
}
if (!this.isControlled()) {
this.update(currentValue_1);
}
triggerEventValues(this, 'change', [
currentValue_1,
options.filter(function (v) { return currentValue_1.indexOf(v.value) > -1; }),
], e);
}
else {
if (value === this.getValue()) {
if (minSelectedCount === 1) {
triggerEventValues(this, 'selectMin', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
if (!this.isControlled()) {
this.update(undefined);
}
triggerEventValues(this, 'change', [undefined, undefined], e);
}
else {
if (!this.isControlled()) {
this.update(value);
}
triggerEventValues(this, 'change', [value, options.find(function (v) { return v.value === value; })], e);
}
}
},
}, null, [mixinValue()]);

View File

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -0,0 +1,9 @@
function getChecked(value, values, multiple) {
if (!multiple) {
return value === values;
}
return (values || []).indexOf(value) > -1;
}
export default {
getChecked: getChecked
};

View File

@ -0,0 +1,69 @@
import { IBaseProps } from '../_util/base';
export type Value = string | number;
export interface ISelectorItem {
/**
* @description 主文案
*/
text: string;
/**
* @description 选项值,在同一个 Selector 中唯一
*/
value: Value;
/**
* @description 辅助文案
*/
subText?: string;
/**
* @description 单个禁用
*/
disabled?: boolean;
}
/**
* @description 筛选器,可供用户进行单选或者多选。
*/
export interface ISelectorProps extends IBaseProps {
/**
* @description 已选择项, 取 items 每一项的 value
*/
value: Value | Value[];
/**
* @description 默认选择项, 取 items 每一项的 value
*/
defaultValue: Value | Value[];
/**
* @description 可选项
*/
options: ISelectorItem[];
/**
* @description 每一项激活时新加类名
*/
activeItemClassName: string;
/**
* @description 每一项激活时样式
*/
activeItemStyle: string;
/**
* @description 是否允许多选
* @default false
*/
multiple: boolean;
/**
* @description 最小选择数量
*/
minSelectedCount: number;
/**
* @description 最大选择数量
*/
maxSelectedCount: number;
disabled?: boolean;
onChange?(value: Value | Value[] | undefined, item: ISelectorItem | ISelectorItem[] | undefined, e: Record<string, any>): void;
/**
* @description 触发最大限制
*/
onSelectMax?(value: Value, item: ISelectorItem, e: Record<string, any>): void;
/**
* @description 触发最小限制
*/
onSelectMin?(value: Value, item: ISelectorItem, e: Record<string, any>): void;
}
export declare const SelectorDefaultProps: Partial<ISelectorProps>;

View File

@ -0,0 +1,11 @@
export var SelectorDefaultProps = {
value: null,
defaultValue: null,
options: null,
activeItemClassName: '',
activeItemStyle: '',
multiple: false,
minSelectedCount: null,
maxSelectedCount: null,
disabled: false,
};