<commit_before>/* eslint no-underscore-dangle: 0 */

import PropTypes from 'prop-types';
import { View, TextInput } from 'react-native';
import React from 'react';
import ModalPicker from 'react-native-modal-selector';

class SelectType extends React.Component {
  getOptions = ({ options }) => {
    if (Array.isArray(options)) {
      return options.map(val => ({ key: val, label: val }));
    }

    return Object.keys(options).map(key => ({ label: key, key: options[key] }));
  };

  render() {
    const { knob, onChange } = this.props;

    const options = this.getOptions(knob);

    const selected = options.filter(({ key }) => knob.value === key)[0].label;

    return (
      <View>
        <ModalPicker
          data={options}
          initValue={knob.value}
          onChange={option => onChange(option.key)}
          animationType="none"
        >
          <TextInput
            style={{
              borderWidth: 1,
              borderColor: '#f7f4f4',
              borderRadius: 2,
              padding: 5,
              color: '#555',
              margin: 10,
            }}
            editable={false}<commit_msg>fix(ondevice-knobs): graceful fail on missing default<commit_after>/* eslint no-underscore-dangle: 0 */

import PropTypes from 'prop-types';
import { View, TextInput } from 'react-native';
import React from 'react';
import ModalPicker from 'react-native-modal-selector';

class SelectType extends React.Component {
  getOptions = ({ options }) => {
    if (Array.isArray(options)) {
      return options.map(val => ({ key: val, label: val }));
    }

    return Object.keys(options).map(key => ({ label: key, key: options[key] }));
  };

  render() {
    const { knob, onChange } = this.props;

    const options = this.getOptions(knob);

    const active = options.filter(({ key }) => knob.value === key)[0];
    const selected = active && active.label;

    return (
      <View>
        <ModalPicker
          data={options}
          initValue={knob.value}
          onChange={option => onChange(option.key)}
          animationType="none"
        >
          <TextInput
            style={{
              borderWidth: 1,
              borderColor: '#f7f4f4',
              borderRadius: 2,
              padding: 5,
              color: '#555',
              margin: 10,
            }}
            editable={false}
{'fraction_non_alphanumeric': 0.14061838204150784, 'fraction_numerical': 0.011012282930961457, 'mean_word_length': 2.136786188579017, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2353805', 'n_tokens_mistral': 691, 'n_tokens_neox': 672, 'n_words': 164}