mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
chore: fix lint issues
This commit is contained in:
parent
83eaa5f838
commit
21447d22a1
|
@ -93,7 +93,7 @@ const Button = styled.button`
|
||||||
|
|
||||||
export interface ComboBoxProps {
|
export interface ComboBoxProps {
|
||||||
onChange?: (val: string) => void;
|
onChange?: (val: string) => void;
|
||||||
options: { value: string; label: string }[];
|
options: Array<{ value: string; label: string }>;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,10 @@ export default class ComboBox extends React.Component<ComboBoxProps, ComboBoxSta
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleTryItClick = () => {
|
||||||
|
this.handleSelect(this.state.value);
|
||||||
|
};
|
||||||
|
|
||||||
handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
this.handleSelect(e.currentTarget.value);
|
this.handleSelect(e.currentTarget.value);
|
||||||
|
@ -176,8 +180,27 @@ export default class ComboBox extends React.Component<ComboBoxProps, ComboBoxSta
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderOption = (option: { value: string; label: string }, idx: number) => {
|
||||||
|
return (
|
||||||
|
<DropDownItem
|
||||||
|
active={idx === this.state.activeItemIdx}
|
||||||
|
key={option.value}
|
||||||
|
// tslint:disable-next-line
|
||||||
|
onMouseDown={() => {
|
||||||
|
this.handleItemClick(option.value, idx);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<small>
|
||||||
|
<strong>{option.label}</strong>
|
||||||
|
</small>
|
||||||
|
<br />
|
||||||
|
{option.value}
|
||||||
|
</DropDownItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { open, value, activeItemIdx } = this.state;
|
const { open, value } = this.state;
|
||||||
const { options, placeholder } = this.props;
|
const { options, placeholder } = this.props;
|
||||||
return (
|
return (
|
||||||
<ComboBoxWrap>
|
<ComboBoxWrap>
|
||||||
|
@ -189,26 +212,8 @@ export default class ComboBox extends React.Component<ComboBoxProps, ComboBoxSta
|
||||||
onBlur={this.handleBlur}
|
onBlur={this.handleBlur}
|
||||||
onKeyDown={this.handleKeyPress}
|
onKeyDown={this.handleKeyPress}
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => this.handleSelect(this.state.value)}> TRY IT </Button>
|
<Button onClick={this.handleTryItClick}> TRY IT </Button>
|
||||||
{open && (
|
{open && <DropDownList>{options.map(this.renderOption)}</DropDownList>}
|
||||||
<DropDownList>
|
|
||||||
{options.map((option, idx) => (
|
|
||||||
<DropDownItem
|
|
||||||
active={idx == activeItemIdx}
|
|
||||||
key={option.value}
|
|
||||||
onMouseDown={() => {
|
|
||||||
this.handleItemClick(option.value, idx);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<small>
|
|
||||||
<strong>{option.label}</strong>
|
|
||||||
</small>
|
|
||||||
<br />
|
|
||||||
{option.value}
|
|
||||||
</DropDownItem>
|
|
||||||
))}
|
|
||||||
</DropDownList>
|
|
||||||
)}
|
|
||||||
</ComboBoxWrap>
|
</ComboBoxWrap>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { render } from 'react-dom';
|
import { render } from 'react-dom';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { resolve as urlResolve } from 'url';
|
||||||
import { RedocStandalone } from '../';
|
import { RedocStandalone } from '../';
|
||||||
import ComboBox from './ComboBox';
|
import ComboBox from './ComboBox';
|
||||||
import * as url from 'url';
|
|
||||||
|
|
||||||
const demos = [
|
const demos = [
|
||||||
{ value: 'https://api.apis.guru/v2/specs/instagram.com/1.0.0/swagger.yaml', label: 'Instagram' },
|
{ value: 'https://api.apis.guru/v2/specs/instagram.com/1.0.0/swagger.yaml', label: 'Instagram' },
|
||||||
|
@ -61,7 +61,7 @@ class DemoApp extends React.Component<
|
||||||
toggleCors = (e: React.ChangeEvent<HTMLInputElement>) => {
|
toggleCors = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const cors = e.currentTarget.checked;
|
const cors = e.currentTarget.checked;
|
||||||
this.setState({
|
this.setState({
|
||||||
cors: cors,
|
cors,
|
||||||
});
|
});
|
||||||
window.history.pushState(
|
window.history.pushState(
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -75,7 +75,7 @@ class DemoApp extends React.Component<
|
||||||
let proxiedUrl = specUrl;
|
let proxiedUrl = specUrl;
|
||||||
if (specUrl !== DEFAULT_SPEC) {
|
if (specUrl !== DEFAULT_SPEC) {
|
||||||
proxiedUrl = cors
|
proxiedUrl = cors
|
||||||
? '\\\\cors.apis.guru/' + url.resolve(window.location.href, specUrl)
|
? '\\\\cors.apis.guru/' + urlResolve(window.location.href, specUrl)
|
||||||
: specUrl;
|
: specUrl;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
@ -155,7 +155,7 @@ render(<DemoApp />, document.getElementById('container'));
|
||||||
/* ====== Helpers ====== */
|
/* ====== Helpers ====== */
|
||||||
function updateQueryStringParameter(uri, key, value) {
|
function updateQueryStringParameter(uri, key, value) {
|
||||||
const keyValue = value === '' ? key : key + '=' + value;
|
const keyValue = value === '' ? key : key + '=' + value;
|
||||||
var re = new RegExp('([?|&])' + key + '=?.*?(&|#|$)', 'i');
|
const re = new RegExp('([?|&])' + key + '=?.*?(&|#|$)', 'i');
|
||||||
if (uri.match(re)) {
|
if (uri.match(re)) {
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
return uri.replace(re, '$1' + keyValue + '$2');
|
return uri.replace(re, '$1' + keyValue + '$2');
|
||||||
|
@ -171,12 +171,12 @@ function updateQueryStringParameter(uri, key, value) {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
var hash = '';
|
let hash = '';
|
||||||
if (uri.indexOf('#') !== -1) {
|
if (uri.indexOf('#') !== -1) {
|
||||||
hash = uri.replace(/.*#/, '#');
|
hash = uri.replace(/.*#/, '#');
|
||||||
uri = uri.replace(/#.*/, '');
|
uri = uri.replace(/#.*/, '');
|
||||||
}
|
}
|
||||||
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
const separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
||||||
return uri + separator + keyValue + hash;
|
return uri + separator + keyValue + hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { OpenAPIInfo } from '../../types';
|
import { OpenAPIInfo } from '../../types';
|
||||||
import { LogoImgEl, LogoWrap, LinkWrap } from './styled.elements';
|
import { LinkWrap, LogoImgEl, LogoWrap } from './styled.elements';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
|
export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { Component } from 'react';
|
||||||
|
|
||||||
import { AppStore } from '../services/';
|
import { AppStore } from '../services/';
|
||||||
import { RedocRawOptions } from '../services/RedocNormalizedOptions';
|
import { RedocRawOptions } from '../services/RedocNormalizedOptions';
|
||||||
import { loadAndBundleSpec } from '../utils';
|
|
||||||
import { OpenAPISpec } from '../types';
|
import { OpenAPISpec } from '../types';
|
||||||
|
import { loadAndBundleSpec } from '../utils';
|
||||||
|
|
||||||
interface StoreProviderProps {
|
interface StoreProviderProps {
|
||||||
specUrl?: string;
|
specUrl?: string;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user