()
| 84 | /* Computed Methods */ |
| 85 | |
| 86 | activeOptions(): [] { |
| 87 | const activeValue = this.state.activeValue; |
| 88 | const configurableProps = ['label', 'value', 'children', 'disabled']; |
| 89 | const formatOptions = (options: any) => { |
| 90 | options.forEach(option => { |
| 91 | if (option.__IS__FLAT__OPTIONS) return; |
| 92 | configurableProps.forEach(prop => { |
| 93 | const value = option[this.parent().props.props[prop] || prop]; |
| 94 | if (value) option[prop] = value; |
| 95 | }); |
| 96 | if (Array.isArray(option.children)) { |
| 97 | formatOptions(option.children); |
| 98 | } |
| 99 | }); |
| 100 | }; |
| 101 | const loadActiveOptions = (options: any, activeOptions: any = []): [] => { |
| 102 | const level = activeOptions.length; |
| 103 | activeOptions[level] = options; |
| 104 | let active = activeValue[level]; |
| 105 | if (active) { |
| 106 | options = options.filter(option => option.value === active)[0]; |
| 107 | if (options && options.children) { |
| 108 | loadActiveOptions(options.children, activeOptions); |
| 109 | } |
| 110 | } |
| 111 | return activeOptions; |
| 112 | }; |
| 113 | |
| 114 | formatOptions(this.state.options); |
| 115 | |
| 116 | return loadActiveOptions(this.state.options); |
| 117 | } |
| 118 | |
| 119 | render() { |
| 120 | const { expandTrigger, popperClass } = this.parent().props; |
no outgoing calls
no test coverage detected