<commit_before>import React from 'react';
import PropTypes from 'prop-types';

import { StyleSheet, Text, TextInput } from 'react-native';

import RNSlider from '@react-native-community/slider';
import { SUSSOL_ORANGE, WARMER_GREY } from '../globalStyles';
import { roundNumber } from '../utilities';
import { FlexRow } from './FlexRow';
import { generalStrings } from '../localization';

/**
 * Component rendering a slider with an additional TextInput in a row.
 * Numbers entered through the TextInput are validated to be a valid number
 * and within the bounds passed as minimumValue and maximumValue.
 *
 * The callback on value changes is invoked when sliding has finished and when
 * a valid number is entered into the TextInput.
 *
 * @prop {Bool}   isDisabled             Indicator whether this component is disabled.
 * @prop {String} minimumTrackTintColour The colour of the track lower than the slider.
 * @prop {String} maximumTrackTintColour The colour of the track greater than the slider.
 * @prop {String} thumbTintColour        The colour of the slider thumb
 * @prop {Number} fractionDigits         How many decimal places.
 * @prop {Number} step                   The steps of the slider. i.e. 0.25 for [.0, .25,.5,.75]
 * @prop {Number} value                  The current value of the input.
 * @prop {Number} onEndEditing           The callback on editing.
 * @prop {Number} minimumValue           The lower bound of valid values.
 * @prop {Number} maximumValue           The upper bound of valid values.
 *
 */
export const Slider = React.forwardRef(
  (
    {
      minimumValue,
      maximumValue,
      minimumTrackTintColour,
      maximumTrackTintColour,
      thumbTintColour,
      fractionDigits,
      step,
      value,
      onEndEditing,
      isDisabled,
    },
    ref
  ) => {
    if (!onEndEditing) throw new Error('Must provide onEndEditing prop!');

    // Current value of the component which is an always-valid Number.
    const [currentValue, setValue] = React.useState(value);

    // The current string value for the text input. Essentially a buffer for<commit_msg>Fix insurance form discount slider incorrect values<commit_after>import React from 'react';
import PropTypes from 'prop-types';

import { StyleSheet, Text, TextInput } from 'react-native';

import RNSlider from '@react-native-community/slider';
import { SUSSOL_ORANGE, WARMER_GREY } from '../globalStyles';
import { roundNumber } from '../utilities';
import { FlexRow } from './FlexRow';
import { generalStrings } from '../localization';

/**
 * Component rendering a slider with an additional TextInput in a row.
 * Numbers entered through the TextInput are validated to be a valid number
 * and within the bounds passed as minimumValue and maximumValue.
 *
 * The callback on value changes is invoked when sliding has finished and when
 * a valid number is entered into the TextInput.
 *
 * @prop {Bool}   isDisabled             Indicator whether this component is disabled.
 * @prop {String} minimumTrackTintColour The colour of the track lower than the slider.
 * @prop {String} maximumTrackTintColour The colour of the track greater than the slider.
 * @prop {String} thumbTintColour        The colour of the slider thumb
 * @prop {Number} fractionDigits         How many decimal places.
 * @prop {Number} step                   The steps of the slider. i.e. 0.25 for [.0, .25,.5,.75]
 * @prop {Number} value                  The current value of the input.
 * @prop {Number} onEndEditing           The callback on editing.
 * @prop {Number} minimumValue           The lower bound of valid values.
 * @prop {Number} maximumValue           The upper bound of valid values.
 *
 */
export const Slider = React.forwardRef(
  (
    {
      minimumValue,
      maximumValue,
      minimumTrackTintColour,
      maximumTrackTintColour,
      thumbTintColour,
      fractionDigits,
      step,
      value,
      onEndEditing,
      isDisabled,
    },
    ref
  ) => {
    if (!onEndEditing) throw new Error('Must provide onEndEditing prop!');

    React.useEffect(() => {
      if (value !== currentValue) {
        setString(value);
        setSlider(value);
      }
    }, [value]);

    // Current value of the component which is an always-valid Number.
    const [currentValue, setValue] = React.useState(value);

    // The current string value for the text input. Essentially a buffer for
{'fraction_non_alphanumeric': 0.08719346049046321, 'fraction_numerical': 0.004087193460490463, 'mean_word_length': 2.954219030520646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5286585', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1170, 'n_words': 478}