<wxs module="utils" src="../wxs/utils.wxs"/>

<van-popup
        bind:close="onClickOverlay"
        close-on-click-overlay="{{ closeOnClickOverlay }}"
        custom-class="van-action-sheet custom-class"
        overlay="{{ overlay }}"
        position="bottom"
        root-portal="{{ rootPortal }}"
        round="{{ round }}"
        safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
        show="{{ show }}"
        z-index="{{ zIndex }}"
>
    <view class="van-action-sheet__header" wx:if="{{ title }}">
        {{ title }}
        <van-icon
                bind:click="onClose"
                custom-class="van-action-sheet__close"
                name="cross"
        />
    </view>
    <view class="van-action-sheet__description van-hairline--bottom" wx:if="{{ description }}">
        {{ description }}
    </view>
    <view class="list-class" wx:if="{{ actions && actions.length }}">
        <!-- button外包一层view，防止actions动态变化，导致渲染时button被打散 -->
        <button
                app-parameter="{{ appParameter }}"
                bindcontact="onContact"
                binderror="onError"
                bindgetphonenumber="onGetPhoneNumber"
                bindgetuserinfo="onGetUserInfo"
                bindlaunchapp="onLaunchApp"
                bindopensetting="onOpenSetting"
                bindtap="{{ item.disabled || item.loading ? '' : 'onSelect' }}"
                class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} {{ item.className || '' }}"
                data-index="{{ index }}"
                hover-class="van-action-sheet__item--hover"
                lang="{{ lang }}"
                open-type="{{ item.disabled || item.loading || (canIUseGetUserProfile && item.openType === 'getUserInfo') ? '' : item.openType }}"
                send-message-img="{{ sendMessageImg }}"
                send-message-path="{{ sendMessagePath }}"
                send-message-title="{{ sendMessageTitle }}"
                session-from="{{ sessionFrom }}"
                show-message-card="{{ showMessageCard }}"
                style="{{ item.color ? 'color: ' + item.color : '' }}"
                wx:for="{{ actions }}"
                wx:key="index"
        >
            <block wx:if="{{ !item.loading }}">
                {{ item.name }}
                <view class="van-action-sheet__subname" wx:if="{{ item.subname }}">{{ item.subname }}</view>
            </block>
            <van-loading custom-class="van-action-sheet__loading" size="22px" wx:else/>
        </button>
    </view>
    <slot/>
    <block wx:if="{{ cancelText }}">
        <view class="van-action-sheet__gap"/>
        <view
                bind:tap="onCancel"
                class="van-action-sheet__cancel"
                hover-class="van-action-sheet__cancel--hover"
                hover-stay-time="70"
        >
            {{ cancelText }}
        </view>
    </block>
</van-popup>
