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,67 @@
<import-sjs
from="./index.sjs"
name="helper"
></import-sjs>
<ant-popup
className="ant-actionsheet-popup"
visible="{{visible}}"
position="bottom"
zIndex="{{zIndex}}"
onClose="onClose"
>
<view
style="{{style}}"
class="ant-actionsheet {{className ? className : ''}} {{helper.isIconMode(actions) ? 'ant-actionsheet-icon' : ''}}"
>
<slot name="title">
<view
a:if="{{title}}"
class="ant-actionsheet-title-wrap"
>
<view class="ant-actionsheet-title-content">{{title}}</view>
</view>
</slot>
<view class="ant-actionsheet-list">
<block
a:for="{{actions}}"
a:for-index="index"
a:for-item="item"
key="{{index}}"
>
<view
class="ant-actionsheet-list-item {{item.disabled ? 'ant-actionsheet-list-item-disabled' : ''}}"
hoverClass="{{item.disabled ? '' : 'ant-actionsheet-list-item-active'}}"
onTap="onAction"
data-index="{{index}}"
data-item="{{item}}"
>
<view
a:if="{{helper.isIconMode(actions)}}"
class="ant-actionsheet-list-item-icon"
style="background-image: url('{{item.icon}}')"
></view>
<view class="ant-actionsheet-list-item-content">
<view class="ant-actionsheet-list-item-title {{item.danger ? 'ant-actionsheet-list-item-title-danger' : ''}}">
{{item.text}}
</view>
<view
a:if="{{item.description}}"
class="ant-actionsheet-list-item-description"
>
{{item.description}}
</view>
</view>
</view>
</block>
</view>
<view class="ant-actionsheet-cancel-gap"></view>
<slot name="cancelText">
<view
class="ant-actionsheet-cancel"
onTap="onClose"
>
{{cancelText}}
</view>
</slot>
</view>
</ant-popup>

View File

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

View File

@ -0,0 +1,14 @@
import { Component, triggerEventOnly, triggerEventValues } from '../_util/simply';
import { ActionSheetDefaultProps } from './props';
Component(ActionSheetDefaultProps, {
onAction: function (e) {
var _a = e.currentTarget.dataset, item = _a.item, index = _a.index;
if (item === null || item === void 0 ? void 0 : item.disabled)
return;
triggerEventOnly(this, 'close', e);
triggerEventValues(this, 'action', [item, index], e);
},
onClose: function (e) {
triggerEventOnly(this, 'close', e);
}
});

View File

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

View File

@ -0,0 +1,96 @@
@import (reference) './variable.less';
@import (reference) '../style/mixins/hairline.less';
@actionsheetPrefix: ant-actionsheet;
.@{actionsheetPrefix} {
padding-left: 24 * @rpx;
padding-right: 24 * @rpx;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
&-title-wrap {
text-align: center;
position: relative;
margin: 0 -24 * @rpx;
}
&-title-content {
display: inline-block;
text-align: left;
padding: 36 * @rpx 30 * @rpx;
font-size: 30 * @rpx;
color: @COLOR_TEXT_ASSIST;
.hairline('bottom', @COLOR_BORDER);
}
&-list {
margin: 0 -24 * @rpx;
}
&-list-item {
color: @COLOR_TEXT_PRIMARY;
padding: 32 * @rpx 30 * @rpx;
text-align: center;
position: relative;
font-size: 36 * @rpx;
.hairline('bottom', @COLOR_BORDER);
&-title-danger {
color: @actionsheet-danger-color;
font-weight: bold;
}
&-description {
color: @COLOR_TEXT_ASSIST;
font-size: 28 * @rpx;
line-height: 40 * @rpx;
margin-top: 8 * @rpx;
}
&-active {
background-color: @COLOR_BORDER;
}
&:last-child {
&&:after {
display: none;
}
}
}
&-list-item-disabled {
.@{actionsheetPrefix}-list-item-icon,
.@{actionsheetPrefix}-list-item-content {
opacity: @opacity-disabled;
}
}
&-cancel-gap {
height: 16 * @rpx;
background: @COLOR_BACKGROUND;
margin: 0 -24 * @rpx;
}
&-cancel {
color: @COLOR_TEXT_PRIMARY;
padding: 32 * @rpx 30 * @rpx;
font-size: 36 * @rpx;
text-align: center;
margin: 0 -24 * @rpx;
&:active {
background-color: @COLOR_BORDER;
}
}
}
.@{actionsheetPrefix}-icon {
.@{actionsheetPrefix}-title-wrap {
text-align: left;
}
.@{actionsheetPrefix}-list-item {
display: flex;
align-items: center;
&-icon {
height: @actionsheet-icon-height;
flex: 0 0 @actionsheet-icon-width;
margin-right: 24 * @rpx;
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
}
&-content {
text-align: left;
}
}
}

View File

@ -0,0 +1,8 @@
function isIconMode(actions) {
return actions.some(function (action) {
return !!action.icon;
});
}
export default {
isIconMode: isIconMode
};

View File

@ -0,0 +1,43 @@
import { IBaseProps } from '../_util/base';
export interface IActionItem {
text: string;
icon: string;
description?: string;
danger?: boolean;
disabled?: boolean;
}
/**
* @description 头像,可展示头像以及用户名等简要信息。
*/
export interface IActionSheetProps extends IBaseProps {
/**
* @description 标题
* @default ""
*/
title: string;
/**
* @description 面板选项列表
* @default []
*/
actions: IActionItem[];
/**
* @description 取消按钮文字
* @default []
*/
cancelText: string;
/**
* @description 是否显示
* @default false
*/
visible: boolean;
zIndex: number;
/**
* @description 点击选项时触发,禁用或加载状态下不会触发
*/
onAction: (aciton: IActionItem, index: number, e: any) => void;
/**
* @description 关闭时触发
*/
onClose: (e: any) => void;
}
export declare const ActionSheetDefaultProps: Partial<IActionSheetProps>;

View File

@ -0,0 +1,8 @@
export var ActionSheetDefaultProps = {
title: '',
actions: [],
cancelText: '取消',
visible: false,
// 弹窗层级
zIndex: 998,
};

View File

@ -0,0 +1,5 @@
@import (reference) '../style/themes/index.less';
@actionsheet-danger-color: @COLOR_RED;
@actionsheet-icon-width: 48 * @rpx;
@actionsheet-icon-height: 48 * @rpx;