index.wxs 651 B

123456789101112131415161718192021222324
  1. var utils = require('../wxs/utils.wxs');
  2. var style = require('../wxs/style.wxs');
  3. function isSelected(tab, valueKey, option) {
  4. return tab.selected && tab.selected[valueKey] === option[valueKey]
  5. }
  6. function optionClass(tab, valueKey, option) {
  7. return utils.bem('cascader__option', { selected: isSelected(tab, valueKey, option), disabled: option.disabled })
  8. }
  9. function optionStyle(data) {
  10. var color = data.option.color || (isSelected(data.tab, data.valueKey, data.option) ? data.activeColor : undefined);
  11. return style({
  12. color
  13. });
  14. }
  15. module.exports = {
  16. isSelected: isSelected,
  17. optionClass: optionClass,
  18. optionStyle: optionStyle,
  19. };