index.wxs 649 B

123456789101112131415161718192021222324
  1. var utils = require('../wxs/utils.wxs');
  2. var style = require('../wxs/style.wxs');
  3. function isSelected(tab, textKey, option) {
  4. return tab.selected && tab.selected[textKey] === option[textKey]
  5. }
  6. function optionClass(tab, textKey, option) {
  7. return utils.bem('cascader__option', { selected: isSelected({ tab, textKey, option }), disabled: option.disabled })
  8. }
  9. function optionStyle(data) {
  10. var color = data.option.color || (isSelected(data.tab, data.textKey, 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. };