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

<view
  wx:if="{{ showWrapper }}"
  class="{{ utils.bem('dropdown-item', direction) }} custom-class"
  style="{{ wrapperStyle }}"
>
  <smart-popup
    show="{{ showPopup }}"
    custom-style="position: absolute;{{ popupStyle }}"
    overlay-style="position: absolute;"
    overlay="{{ overlay }}"
    position="{{ direction === 'down' ? 'top' : 'bottom' }}"
    duration="{{ transition ? duration : 0 }}"
    safe-area-tab-bar="{{ safeAreaTabBar }}"
    safe-area-inset-bottom="{{ false }}"
    close-on-click-overlay="{{ closeOnClickOverlay }}"
    rootPortal="{{ rootPortal }}"
    bind:enter="onOpen"
    bind:leave="onClose"
    bind:close="toggle"
    bind:after-enter="onOpened"
    bind:after-leave="onClosed"
  >
    <scroll-view scroll-y style="{{scrollStyle}}">
      <smart-cell
        wx:for="{{ options }}"
        wx:key="value"
        data-option="{{ item }}"
        class="{{ utils.bem('dropdown-item__option', { active: item.value === value, first: direction !== 'up' && !index }) }}"
        clickable
        icon="{{ item.icon }}"
        bind:tap="onOptionTap"
      >
        <view
          slot="title"
          class="smart-dropdown-item__title item-title-class"
          style="{{ item.value === value  ? 'color:' + activeColor : '' }}"
        >
          {{ item.text }}
        </view>
        <smart-icon
          wx:if="{{ item.value === value }}"
          name="{{ checkMarkIcon }}"
          class="smart-dropdown-item__icon"
          color="{{ activeColor || checkMarkIconColor }}"
        />
      </smart-cell>
      <slot />
    </scroll-view>
  </smart-popup>
</view>
