Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Dec 10, 2019
1 parent 664f095 commit b8c5964
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import React, { useCallback } from 'react';

import { EuiFieldNumber, EuiFlexGroup, EuiFlexItem, EuiButtonIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { Range } from './range';
import { NumberListRange } from './range';

export interface NumberRowProps {
autoFocus: boolean;
disableDelete: boolean;
isInvalid: boolean;
labelledbyId: string;
model: NumberRowModel;
range: Range;
range: NumberListRange;
onBlur(): void;
onChange({ id, value }: { id: string; value: string }): void;
onDelete(index: string): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const RANGE_RE = new RegExp(
'^\\s*([\\[|\\(])\\s*' + _RE_NUMBER + '\\s*,\\s*' + _RE_NUMBER + '\\s*([\\]|\\)])\\s*$'
);

export class Range {
export class NumberListRange {
constructor(
public minInclusive: boolean,
public min: number,
Expand All @@ -62,7 +62,7 @@ export class Range {
}
}

export function parseRange(input: string): Range {
export function parseRange(input: string): NumberListRange {
const match = String(input).match(RANGE_RE);
if (!match) {
throw new TypeError('expected input to be in interval notation e.g., (100, 200]');
Expand All @@ -76,5 +76,10 @@ export function parseRange(input: string): Range {

const [minInclusive, min, max, maxInclusive] = args;

return new Range(minInclusive as boolean, min as number, max as number, maxInclusive as boolean);
return new NumberListRange(
minInclusive as boolean,
min as number,
max as number,
maxInclusive as boolean
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import {
getNextModel,
getRange,
} from './utils';
import { Range } from './range';
import { NumberListRange } from './range';
import { NumberRowModel } from './number_row';

describe('NumberList utils', () => {
let modelList: NumberRowModel[];
let range: Range;
let range: NumberListRange;

beforeEach(() => {
modelList = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { last } from 'lodash';
import { i18n } from '@kbn/i18n';
import { htmlIdGenerator } from '@elastic/eui';

import { parseRange, Range } from './range';
import { parseRange, NumberListRange } from './range';
import { NumberRowModel } from './number_row';

const EMPTY_STRING = '';
Expand All @@ -34,15 +34,15 @@ function parse(value: string) {
return isNaN(parsedValue) ? EMPTY_STRING : parsedValue;
}

function getRange(range?: string): Range {
function getRange(range?: string): NumberListRange {
try {
return range ? parseRange(range) : defaultRange;
} catch (e) {
throw new TypeError('Unable to parse range: ' + e.message);
}
}

function validateValue(value: number | '', numberRange: Range) {
function validateValue(value: number | '', numberRange: NumberListRange) {
const result: { isInvalid: boolean; error?: string } = {
isInvalid: false,
};
Expand Down Expand Up @@ -76,7 +76,7 @@ function validateOrder(list: Array<number | undefined>) {
return result;
}

function getNextModel(list: NumberRowModel[], range: Range): NumberRowModel {
function getNextModel(list: NumberRowModel[], range: NumberListRange): NumberRowModel {
const lastValue = last(list).value;
let next = Number(lastValue) ? Number(lastValue) + 1 : 1;

Expand Down Expand Up @@ -104,7 +104,7 @@ function getInitModelList(list: Array<number | undefined>): NumberRowModel[] {
function getUpdatedModels(
numberList: Array<number | undefined>,
modelList: NumberRowModel[],
numberRange: Range,
numberRange: NumberListRange,
invalidOrderModelIndex?: number
): NumberRowModel[] {
if (!numberList.length) {
Expand Down

0 comments on commit b8c5964

Please sign in to comment.