Skip to content

Commit

Permalink
feat: export TypeScript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed May 16, 2018
1 parent e06f6e8 commit 9115be8
Show file tree
Hide file tree
Showing 53 changed files with 159 additions and 67 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ node_modules
lib/
stats.json
cypress/
bundles
bundles/
typings/
cli/index.js

/benchmark/revisions
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*
!bundles/*
!typings/*
!package.json
!README.md
!LICENSE
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"React.js"
],
"main": "bundles/redoc.lib.js",
"types": "typings/index.d.ts",
"scripts": {
"start": "webpack-dev-server --mode=development --env.playground --hot --config demo/webpack.config.ts",
"start:prod": "webpack-dev-server --env.playground --mode=production --config demo/webpack.config.ts",
Expand All @@ -37,6 +38,7 @@
"bundle:standalone": "webpack --env.standalone --mode=production",
"bundle:lib": "webpack --mode=production",
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone",
"declarations": "rimraf typings && tsc --emitDeclarationOnly -p tsconfig.lib.json",
"stats": "webpack --env.standalone --json --profile --mode=production > stats.json",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
Expand Down
7 changes: 6 additions & 1 deletion src/common-elements/dropdown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';
import Dropdown from 'react-dropdown';

import styled, { StyledComponentClass, withProps } from '../styled-components';
import styled, {
ResolvedThemeInterface,
StyledComponentClass,
withProps,
} from '../styled-components';

export interface DropdownOption {
label: string;
Expand Down
8 changes: 7 additions & 1 deletion src/common-elements/fields-layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { transparentize } from 'polished';
import styled, { withProps } from '../styled-components';
import * as React from 'react';

import styled, {
ResolvedThemeInterface,
StyledComponentClass,
withProps,
} from '../styled-components';
import { deprecatedCss } from './mixins';

export const PropertiesTableCaption = styled.caption`
Expand Down
4 changes: 3 additions & 1 deletion src/common-elements/fields.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { transparentize } from 'polished';
import styled from '../styled-components';
import * as React from 'react';

import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
import { PropertyNameCell } from './fields-layout';

export const ClickablePropertyNameCell = PropertyNameCell.extend`
Expand Down
5 changes: 4 additions & 1 deletion src/common-elements/headers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import styled, { css } from '../styled-components';
import * as React from 'react';
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';

import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';

const headerFontSize = {
1: '1.85714em',
Expand Down
5 changes: 4 additions & 1 deletion src/common-elements/linkify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import styled, { css } from '../styled-components';
import * as React from 'react';
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';

import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';

// tslint:disable-next-line
export const linkifyMixin = className => css`
Expand Down
4 changes: 3 additions & 1 deletion src/common-elements/mixins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { css } from '../styled-components';
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';

import { css, StyledComponentClass } from '../styled-components';

export const deprecatedCss = css`
text-decoration: line-through;
Expand Down
3 changes: 2 additions & 1 deletion src/common-elements/panels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled, { media } from '../styled-components';
import * as React from 'react';
import styled, { media, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';

export const MiddlePanel = styled.div`
width: calc(100% - ${props => props.theme.rightPanel.width});
Expand Down
4 changes: 3 additions & 1 deletion src/common-elements/samples.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import styled from '../styled-components';
import * as React from 'react';

import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';

export const SampleControls = styled.div`
opacity: 0.4;
Expand Down
7 changes: 6 additions & 1 deletion src/common-elements/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import styled, { withProps } from '../styled-components';
import * as React from 'react';
import styled, {
ResolvedThemeInterface,
StyledComponentClass,
withProps,
} from '../styled-components';

export const OneOfList = styled.ul`
margin: 0;
Expand Down
6 changes: 5 additions & 1 deletion src/common-elements/shelfs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import styled, { withProps } from '../styled-components';
import styled, {
ResolvedThemeInterface,
StyledComponentClass,
withProps,
} from '../styled-components';

const directionMap = {
left: '90deg',
Expand Down
4 changes: 2 additions & 2 deletions src/common-elements/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tabs as ReactTabs } from 'react-tabs';
import styled from '../styled-components';
import { Tabs as ReactTabs, TabsProps } from 'react-tabs';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';

export { Tab, TabList, TabPanel } from 'react-tabs';

Expand Down
2 changes: 1 addition & 1 deletion src/components/ApiInfo/ApiInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
InfoSpanBoxWrap,
} from './styled.elements';

interface ApiInfoProps {
export interface ApiInfoProps {
store: AppStore;
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/ApiInfo/styled.elements.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from '../../styled-components';
import { AnchorHTMLAttributes, ClassAttributes, HTMLAttributes } from 'react';

import { H1, MiddlePanel } from '../../common-elements';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

const delimiterWidth = 15;

Expand Down
2 changes: 1 addition & 1 deletion src/components/ApiLogo/styled.elements.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from '../../styled-components';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

export const LogoImgEl = styled.img`
max-height: ${props => props.theme.logo.maxHeight};
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContentItems/ContentItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ContentItems extends React.Component<{
}
}

interface ContentItemProps {
export interface ContentItemProps {
item: ContentItemModel;
}

Expand Down
8 changes: 7 additions & 1 deletion src/components/Endpoint/styled.elements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import styled, { withProps } from '../../styled-components';
import { ClassAttributes, HTMLAttributes, HTMLProps } from 'react';

import styled, {
ResolvedThemeInterface,
StyledComponentClass,
withProps,
} from '../../styled-components';

export const OperationEndpointWrap = styled.div`
cursor: pointer;
Expand Down
4 changes: 2 additions & 2 deletions src/components/JsonViewer/JsonViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import styled from '../../styled-components';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

import { SampleControls } from '../../common-elements';
import { CopyButtonWrapper } from '../../common-elements/CopyButtonWrapper';
import { jsonToHTML } from '../../utils/jsonToHtml';
import { jsonStyles } from './style';

interface JsonProps {
export interface JsonProps {
data: any;
className?: string;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/JsonViewer/style.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { css } from '../../styled-components';
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';
import { css, ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

export const jsonStyles = css`
.redoc-json > .collapser {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Loading/Spinner.svg.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import styled, { keyframes } from '../../styled-components';
import styled, {
keyframes,
ResolvedThemeInterface,
StyledComponentClass,
} from '../../styled-components';

const _Spinner = (props: { className?: string; color: string }) => (
<svg className={props.className} version="1.1" width="512" height="512" viewBox="0 0 512 512">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Markdown/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from '../../styled-components';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

import * as DOMPurify from 'dompurify';
import { AppStore, MarkdownRenderer } from '../../services';
Expand Down
4 changes: 3 additions & 1 deletion src/components/Markdown/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';

import { headerCommonMixin, linkifyMixin } from '../../common-elements';
import { css } from '../../styled-components';
import { css, ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

export const markdownCss = css`
p {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Operation/Operation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const OperationRow = Row.extend`
}
`;

interface OperationProps {
export interface OperationProps {
operation: OperationType;
}

Expand Down
13 changes: 0 additions & 13 deletions src/components/OptionsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@ import * as React from 'react';

import { RedocNormalizedOptions } from '../services/RedocNormalizedOptions';

// TODO: contribute declarations to @types/react once 16.3 is released
type ReactProviderComponent<T> = React.ComponentType<{ value: T }>;
type ReactConsumerComponent<T> = React.ComponentType<{ children: ((value: T) => React.ReactNode) }>;

interface ReactContext<T> {
Provider: ReactProviderComponent<T>;
Consumer: ReactConsumerComponent<T>;
}

declare module 'react' {
function createContext<T>(defatulValue: T): ReactContext<T>;
}

export const OptionsContext = React.createContext(new RedocNormalizedOptions({}));
export const OptionsProvider = OptionsContext.Provider;
export const OptionsConsumer = OptionsContext.Consumer;
2 changes: 1 addition & 1 deletion src/components/Parameters/Parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function safePush(obj, prop, item) {
obj[prop].push(item);
}

interface ParametersProps {
export interface ParametersProps {
parameters?: FieldModel[];
body?: RequestBodyModel;
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/PayloadSamples/styled.elements.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from '../../styled-components';
import { ClassAttributes, HTMLAttributes } from 'react';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';

import { StyledDropdown } from '../../common-elements';
import { DropdownProps, StyledDropdown } from '../../common-elements';

export const MimeLabel = styled.div`
border-bottom: 1px solid rgba(255, 255, 255, 0.9);
Expand Down
4 changes: 3 additions & 1 deletion src/components/Redoc/Redoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class Redoc extends React.Component<RedocProps> {
}

render() {
const { store: { spec, menu, options, search, marker } } = this.props;
const {
store: { spec, menu, options, search, marker },
} = this.props;
const store = this.props.store;
return (
<ThemeProvider theme={options.theme}>
Expand Down
9 changes: 7 additions & 2 deletions src/components/Redoc/elements.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import styled, { media } from '../../styled-components';
export { ClassAttributes } from 'react';
import { ClassAttributes, HTMLAttributes } from 'react';

import styled, {
media,
ResolvedThemeInterface,
StyledComponentClass,
} from '../../styled-components';

export const RedocWrap = styled.div`
font-family: ${props => props.theme.baseFont.family};
Expand Down
7 changes: 4 additions & 3 deletions src/components/Responses/styled.elements.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import styled from '../../styled-components';

import { transparentize } from 'polished';
import { ClassAttributes, HTMLAttributes } from 'react';

import { UnderlinedHeader } from '../../common-elements';
import { ResponseTitle } from './ResponseTitle';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
import { ResponseTitle, ResponseTitleProps } from './ResponseTitle';

export const StyledResponseTitle = styled(ResponseTitle)`
padding: 10px;
Expand Down
6 changes: 5 additions & 1 deletion src/components/Schema/ObjectSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export class ObjectSchema extends React.Component<ObjectSchemaProps> {
}

render() {
const { schema: { fields = [] }, showTitle, discriminator } = this.props;
const {
schema: { fields = [] },
showTitle,
discriminator,
} = this.props;

const needFilter = this.props.skipReadOnly || this.props.skipWriteOnly;

Expand Down
5 changes: 4 additions & 1 deletion src/components/Schema/OneOfSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class OneOfButton extends React.Component<OneOfButtonProps> {
@observer
export class OneOfSchema extends React.Component<SchemaProps> {
render() {
const { schema: { oneOf }, schema } = this.props;
const {
schema: { oneOf },
schema,
} = this.props;

if (oneOf === undefined) {
return null;
Expand Down
8 changes: 7 additions & 1 deletion src/components/SearchBox/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { MenuItem } from '../SideMenu/MenuItem';
import { MarkerService } from '../../services/MarkerService';
import { SearchDocument } from '../../services/SearchWorker.worker';

import { ClearIcon, SearchIcon, SearchInput, SearchResultsBox, SearchWrap } from './elements';
import {
ClearIcon,
SearchIcon,
SearchInput,
SearchResultsBox,
SearchWrap,
} from './styled.elements';

export interface SearchBoxProps {
search: SearchStore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import styled from '../../styled-components';

import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
import { MenuItemLabel } from '../SideMenu/styled.elements';

export const SearchWrap = styled.div`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { transparentize } from 'polished';
import * as React from 'react';

import styled from '../../styled-components';

import { UnderlinedHeader } from '../../common-elements/headers';
Expand Down
2 changes: 1 addition & 1 deletion src/components/SideMenu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IMenuItem, OperationModel } from '../../services';
import { MenuItems } from './MenuItems';
import { MenuItemLabel, MenuItemLi, MenuItemTitle, OperationBadge } from './styled.elements';

interface MenuItemProps {
export interface MenuItemProps {
item: IMenuItem;
onActivate?: (item: IMenuItem) => void;
withoutChildren?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/SideMenu/MenuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IMenuItem } from '../../services';
import { MenuItem } from './MenuItem';
import { MenuItemUl } from './styled.elements';

interface MenuItemsProps {
export interface MenuItemsProps {
items: IMenuItem[];
active?: boolean;
onActivate?: (item: IMenuItem) => void;
Expand Down
4 changes: 4 additions & 0 deletions src/components/SideMenu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './MenuItem';
export * from './MenuItems';
export * from './SideMenu';
export * from './styled.elements';

0 comments on commit 9115be8

Please sign in to comment.