(props: Props)
| 162 | } |
| 163 | |
| 164 | export function ColumnMap(props: Props) { |
| 165 | const options = getColumnMapOptions(props); |
| 166 | if (props.specRole.allowNone) { |
| 167 | options.unshift({ |
| 168 | key: -1, |
| 169 | text: strings.selectNone, |
| 170 | }); |
| 171 | } |
| 172 | const hasSelection = options.reduce((p, c) => { |
| 173 | return p || c.selected; |
| 174 | }, false); |
| 175 | if (!hasSelection) { |
| 176 | selectFirst(options); |
| 177 | } |
| 178 | let signals: NewSignal[]; |
| 179 | if (props.explorer.viewer && props.explorer.viewer.vegaSpec) { |
| 180 | if (props.specRole.signals) { |
| 181 | signals = props.explorer.viewer.vegaSpec.signals.filter(s => props.specRole.signals.indexOf(s.name) >= 0); |
| 182 | } |
| 183 | } |
| 184 | const label = roleLabels[props.specRole.role]; |
| 185 | const signalElements = !props.hideSignals && signals && signals.map((signal, i) => ( |
| 186 | <Signal |
| 187 | key={i} |
| 188 | explorer={props.explorer} |
| 189 | signal={signal} |
| 190 | onChange={value => props.onChangeSignal && props.onChangeSignal(signal.name, value)} |
| 191 | collapseLabel={props.collapseLabel} |
| 192 | /> |
| 193 | )); |
| 194 | return ( |
| 195 | <div |
| 196 | className="sanddance-columnMap" |
| 197 | > |
| 198 | {props.prefix} |
| 199 | {!props.hideDropdown && ( |
| 200 | <Dropdown |
| 201 | componentRef={props.componentRef} |
| 202 | collapseLabel={props.collapseLabel} |
| 203 | disabled={props.disabled} |
| 204 | label={label} |
| 205 | options={options} |
| 206 | onChange={(e, o) => |
| 207 | props.changeColumnMapping(props.specRole.role, typeof o.data === 'string' ? o.data : SandDance.VegaDeckGl.util.clone(o.data)) |
| 208 | } |
| 209 | onDismiss={props.onDismiss} |
| 210 | /> |
| 211 | )} |
| 212 | {signalElements} |
| 213 | {props.suffix} |
| 214 | </div> |
| 215 | ); |
| 216 | } |
nothing calls this directly
no test coverage detected