tabs.wxml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <import src="../common/template/badge.wxml" />
  2. <import src="../common/template/icon.wxml" />
  3. <wxs src="./tabs.wxs" module="filters" />
  4. <wxs src="../common/utils.wxs" module="_" />
  5. <view style="{{_._style([style, customStyle])}}" class="{{_.cls(classPrefix, [placement])}} class {{prefix}}-class">
  6. <t-sticky
  7. t-class="{{_.cls(classPrefix + '__sticky', [placement])}}"
  8. disabled="{{ !sticky }}"
  9. z-index="{{ stickyProps.zIndex || '1' }}"
  10. offset-top="{{ stickyProps.offsetTop || 0 }}"
  11. container="{{ stickyProps.container }}"
  12. bind:scroll="onTouchScroll"
  13. >
  14. <view class="{{_.cls(classPrefix + '__wrapper', [theme])}}">
  15. <scroll-view
  16. class="{{_.cls(classPrefix + '__scroll', [placement, ['split', split]])}}"
  17. enhanced
  18. enable-flex
  19. scroll-left="{{offset}}"
  20. scroll-x="{{true}}"
  21. scroll-anchoring
  22. scroll-with-animation
  23. enable-passive
  24. show-scrollbar="{{false}}"
  25. type="list"
  26. bind:scroll="onScroll"
  27. >
  28. <view class="{{_.cls(classPrefix + '__nav', [placement, ['evenly', spaceEvenly]])}}" aria-role="tablist">
  29. <view
  30. wx:for="{{tabs}}"
  31. wx:key="index"
  32. data-index="{{index}}"
  33. class="{{_.cls(classPrefix + '__item', [theme, ['evenly', spaceEvenly], placement, ['disabled', item.disabled], ['active', currentIndex === index]])}} {{currentIndex === index ? prefix + '-class-active' : ''}} {{prefix}}-class-item"
  34. bind:tap="onTabTap"
  35. aria-role="tab"
  36. aria-controls="{{tabID + '_panel_' + index}}"
  37. aria-selected="{{currentIndex === index}}"
  38. aria-disabled="{{item.disabled}}"
  39. aria-label="{{ ariaLabel || (item.badgeProps.dot || item.badgeProps.count ? item.label + _.getBadgeAriaLabel({ ...item.badgeProps }) : '') }}"
  40. >
  41. <view
  42. class="{{_.cls(classPrefix + '__item-inner', [theme, ['active', currentIndex === index]])}}"
  43. aria-hidden="{{ item.badgeProps.dot || item.badgeProps.count }}"
  44. >
  45. <template wx:if="{{item.icon}}" is="icon" data="{{ tClass: classPrefix + '__icon', ...item.icon }}" />
  46. <block wx:if="{{item.badgeProps}}">
  47. <template
  48. is="badge"
  49. data="{{ ...item.badgeProps, content: item.label, tClass: _.cls(classPrefix + '__badge', [ ['disabled', item.disabled], ['active', currentIndex === index]])}}"
  50. />
  51. </block>
  52. <block wx:else>{{item.label}}</block>
  53. </view>
  54. <view wx:if="{{theme == 'card' && currentIndex - 1 == index}}" class="{{classPrefix}}__item-prefix" />
  55. <view wx:if="{{theme == 'card' && currentIndex + 1 == index}}" class="{{classPrefix}}__item-suffix" />
  56. </view>
  57. <view
  58. wx:if="{{theme == 'line' && showBottomLine}}"
  59. class="{{_.cls(classPrefix + '__track', [placement])}} {{prefix}}-class-track"
  60. style="{{trackStyle}}"
  61. />
  62. </view>
  63. </scroll-view>
  64. </view>
  65. </t-sticky>
  66. <slot name="middle" />
  67. <view
  68. class="{{_.cls(classPrefix + '__content', [['animated', animation]])}}"
  69. bind:touchstart="onTouchStart"
  70. bind:touchmove="onTouchMove"
  71. bind:touchend="onTouchEnd"
  72. bind:touchcancel="onTouchEnd"
  73. >
  74. <view
  75. class="{{classPrefix}}__content-inner {{prefix}}-class-content"
  76. style="{{ filters.animate({duration: animation.duration, currentIndex:currentIndex}) }}"
  77. >
  78. <slot />
  79. </view>
  80. </view>
  81. </view>