All files / molecule/accordion/src settings.js

96% Statements 24/25
62.5% Branches 5/8
100% Functions 6/6
95.83% Lines 23/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 731x 1x 1x 1x 1x 1x 1x   1x         1x   1x 1x             1x 1x     1x       1x               3x   1x 29x     29x     1x               1x             1x         1x        
export const BASE_CLASS = 'sui-MoleculeAccordion'
export const BASE_CLASS_ELEMENT = 'sui-MoleculeAccordionElement'
export const BASE_CLASS_ITEM = `${BASE_CLASS}Item`
export const BASE_CLASS_ITEM_HEADER = `${BASE_CLASS_ITEM}Header`
export const BASE_CLASS_ITEM_HEADER_ICON = `${BASE_CLASS_ITEM_HEADER}Icon`
export const BASE_CLASS_ITEM_PANEL = `${BASE_CLASS_ITEM}Panel`
export const BASE_CLASS_ITEM_PANEL_CONTENT = `${BASE_CLASS_ITEM}PanelContent`
 
export const BEHAVIOR = {
  SINGLE: 'single',
  MULTIPLE: 'multiple'
}
 
const behaviors = {
  [BEHAVIOR.SINGLE]: ({value, values}) => {
    const hasValue = values.includes(value)
    return {
      value,
      isExpanded: !hasValue,
      values: hasValue ? [] : [value]
    }
  },
  [BEHAVIOR.MULTIPLE]: ({value, values}) => {
    const hasValue = values.includes(value)
    return {
      value,
      isExpanded: !hasValue,
      values: hasValue ? values.filter(val => val !== value) : [...values, value]
    }
  },
  [undefined]: ({value, isExpanded, values}) => {
    return {
      value,
      isExpanded,
      values
    }
  }
}
 
export const getBehavior = behaviorName => behaviors[behaviorName]
 
export const getIcon = ({iconProp, isExpanded}, {iconExpanded, iconCollapsed}) => {
  Iif (iconProp) {
    return iconProp
  }
  return isExpanded ? iconExpanded : iconCollapsed
}
 
export const SPACING = {
  XS: 'xs',
  S: 's',
  M: 'm',
  L: 'l',
  XL: 'xl'
}
 
export const ANIMATION_DURATION = {
  NONE: 0,
  FAST: 100,
  NORMAL: 300,
  SLOW: 500
}
 
export const HEADER_ICON_POSITION = {
  LEFT: 'left',
  RIGHT: 'right'
}
 
export const HEADER_LABEL_WRAPS = {
  NO_WRAP: 'noWrap',
  WRAP: 'wrap'
}