Skip to content

Commit 9115be8

Browse files
committed
feat: export TypeScript typings
1 parent e06f6e8 commit 9115be8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+159
-67
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ node_modules
2424
lib/
2525
stats.json
2626
cypress/
27-
bundles
27+
bundles/
28+
typings/
2829
cli/index.js
2930

3031
/benchmark/revisions

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*
22
!bundles/*
3+
!typings/*
34
!package.json
45
!README.md
56
!LICENSE

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"React.js"
2424
],
2525
"main": "bundles/redoc.lib.js",
26+
"types": "typings/index.d.ts",
2627
"scripts": {
2728
"start": "webpack-dev-server --mode=development --env.playground --hot --config demo/webpack.config.ts",
2829
"start:prod": "webpack-dev-server --env.playground --mode=production --config demo/webpack.config.ts",
@@ -37,6 +38,7 @@
3738
"bundle:standalone": "webpack --env.standalone --mode=production",
3839
"bundle:lib": "webpack --mode=production",
3940
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone",
41+
"declarations": "rimraf typings && tsc --emitDeclarationOnly -p tsconfig.lib.json",
4042
"stats": "webpack --env.standalone --json --profile --mode=production > stats.json",
4143
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
4244
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",

src/common-elements/dropdown.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import * as React from 'react';
12
import Dropdown from 'react-dropdown';
23

3-
import styled, { StyledComponentClass, withProps } from '../styled-components';
4+
import styled, {
5+
ResolvedThemeInterface,
6+
StyledComponentClass,
7+
withProps,
8+
} from '../styled-components';
49

510
export interface DropdownOption {
611
label: string;

src/common-elements/fields-layout.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { transparentize } from 'polished';
2-
import styled, { withProps } from '../styled-components';
2+
import * as React from 'react';
3+
4+
import styled, {
5+
ResolvedThemeInterface,
6+
StyledComponentClass,
7+
withProps,
8+
} from '../styled-components';
39
import { deprecatedCss } from './mixins';
410

511
export const PropertiesTableCaption = styled.caption`

src/common-elements/fields.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { transparentize } from 'polished';
2-
import styled from '../styled-components';
2+
import * as React from 'react';
3+
4+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
35
import { PropertyNameCell } from './fields-layout';
46

57
export const ClickablePropertyNameCell = PropertyNameCell.extend`

src/common-elements/headers.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import styled, { css } from '../styled-components';
1+
import * as React from 'react';
2+
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';
3+
4+
import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
25

36
const headerFontSize = {
47
1: '1.85714em',

src/common-elements/linkify.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import styled, { css } from '../styled-components';
1+
import * as React from 'react';
2+
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';
3+
4+
import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
25

36
// tslint:disable-next-line
47
export const linkifyMixin = className => css`

src/common-elements/mixins.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { css } from '../styled-components';
1+
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';
2+
3+
import { css, StyledComponentClass } from '../styled-components';
24

35
export const deprecatedCss = css`
46
text-decoration: line-through;

src/common-elements/panels.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import styled, { media } from '../styled-components';
1+
import * as React from 'react';
2+
import styled, { media, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
23

34
export const MiddlePanel = styled.div`
45
width: calc(100% - ${props => props.theme.rightPanel.width});

src/common-elements/samples.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import styled from '../styled-components';
1+
import * as React from 'react';
2+
3+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
24

35
export const SampleControls = styled.div`
46
opacity: 0.4;

src/common-elements/schema.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import styled, { withProps } from '../styled-components';
1+
import * as React from 'react';
2+
import styled, {
3+
ResolvedThemeInterface,
4+
StyledComponentClass,
5+
withProps,
6+
} from '../styled-components';
27

38
export const OneOfList = styled.ul`
49
margin: 0;

src/common-elements/shelfs.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import * as React from 'react';
2-
import styled, { withProps } from '../styled-components';
2+
import styled, {
3+
ResolvedThemeInterface,
4+
StyledComponentClass,
5+
withProps,
6+
} from '../styled-components';
37

48
const directionMap = {
59
left: '90deg',

src/common-elements/tabs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Tabs as ReactTabs } from 'react-tabs';
2-
import styled from '../styled-components';
1+
import { Tabs as ReactTabs, TabsProps } from 'react-tabs';
2+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
33

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

src/components/ApiInfo/ApiInfo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
InfoSpanBoxWrap,
1616
} from './styled.elements';
1717

18-
interface ApiInfoProps {
18+
export interface ApiInfoProps {
1919
store: AppStore;
2020
}
2121

src/components/ApiInfo/styled.elements.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import styled from '../../styled-components';
1+
import { AnchorHTMLAttributes, ClassAttributes, HTMLAttributes } from 'react';
22

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

56
const delimiterWidth = 15;
67

src/components/ApiLogo/styled.elements.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import styled from '../../styled-components';
2+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
33

44
export const LogoImgEl = styled.img`
55
max-height: ${props => props.theme.logo.maxHeight};

src/components/ContentItems/ContentItems.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class ContentItems extends React.Component<{
2222
}
2323
}
2424

25-
interface ContentItemProps {
25+
export interface ContentItemProps {
2626
item: ContentItemModel;
2727
}
2828

src/components/Endpoint/styled.elements.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import styled, { withProps } from '../../styled-components';
1+
import { ClassAttributes, HTMLAttributes, HTMLProps } from 'react';
2+
3+
import styled, {
4+
ResolvedThemeInterface,
5+
StyledComponentClass,
6+
withProps,
7+
} from '../../styled-components';
28

39
export const OperationEndpointWrap = styled.div`
410
cursor: pointer;

src/components/JsonViewer/JsonViewer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as React from 'react';
2-
import styled from '../../styled-components';
2+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
33

44
import { SampleControls } from '../../common-elements';
55
import { CopyButtonWrapper } from '../../common-elements/CopyButtonWrapper';
66
import { jsonToHTML } from '../../utils/jsonToHtml';
77
import { jsonStyles } from './style';
88

9-
interface JsonProps {
9+
export interface JsonProps {
1010
data: any;
1111
className?: string;
1212
}

src/components/JsonViewer/style.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { css } from '../../styled-components';
1+
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';
2+
import { css, ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
23

34
export const jsonStyles = css`
45
.redoc-json > .collapser {

src/components/Loading/Spinner.svg.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import * as React from 'react';
2-
import styled, { keyframes } from '../../styled-components';
2+
import styled, {
3+
keyframes,
4+
ResolvedThemeInterface,
5+
StyledComponentClass,
6+
} from '../../styled-components';
37

48
const _Spinner = (props: { className?: string; color: string }) => (
59
<svg className={props.className} version="1.1" width="512" height="512" viewBox="0 0 512 512">

src/components/Markdown/Markdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import styled from '../../styled-components';
2+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
33

44
import * as DOMPurify from 'dompurify';
55
import { AppStore, MarkdownRenderer } from '../../services';

src/components/Markdown/styles.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { InterpolationFunction, Styles, ThemeProps } from 'styled-components';
2+
13
import { headerCommonMixin, linkifyMixin } from '../../common-elements';
2-
import { css } from '../../styled-components';
4+
import { css, ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
35

46
export const markdownCss = css`
57
p {

src/components/Operation/Operation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const OperationRow = Row.extend`
3535
}
3636
`;
3737

38-
interface OperationProps {
38+
export interface OperationProps {
3939
operation: OperationType;
4040
}
4141

src/components/OptionsProvider.ts

-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ import * as React from 'react';
33

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

6-
// TODO: contribute declarations to @types/react once 16.3 is released
7-
type ReactProviderComponent<T> = React.ComponentType<{ value: T }>;
8-
type ReactConsumerComponent<T> = React.ComponentType<{ children: ((value: T) => React.ReactNode) }>;
9-
10-
interface ReactContext<T> {
11-
Provider: ReactProviderComponent<T>;
12-
Consumer: ReactConsumerComponent<T>;
13-
}
14-
15-
declare module 'react' {
16-
function createContext<T>(defatulValue: T): ReactContext<T>;
17-
}
18-
196
export const OptionsContext = React.createContext(new RedocNormalizedOptions({}));
207
export const OptionsProvider = OptionsContext.Provider;
218
export const OptionsConsumer = OptionsContext.Consumer;

src/components/Parameters/Parameters.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function safePush(obj, prop, item) {
1717
obj[prop].push(item);
1818
}
1919

20-
interface ParametersProps {
20+
export interface ParametersProps {
2121
parameters?: FieldModel[];
2222
body?: RequestBodyModel;
2323
}

src/components/PayloadSamples/styled.elements.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import styled from '../../styled-components';
1+
import { ClassAttributes, HTMLAttributes } from 'react';
2+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
23

3-
import { StyledDropdown } from '../../common-elements';
4+
import { DropdownProps, StyledDropdown } from '../../common-elements';
45

56
export const MimeLabel = styled.div`
67
border-bottom: 1px solid rgba(255, 255, 255, 0.9);

src/components/Redoc/Redoc.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export class Redoc extends React.Component<RedocProps> {
3232
}
3333

3434
render() {
35-
const { store: { spec, menu, options, search, marker } } = this.props;
35+
const {
36+
store: { spec, menu, options, search, marker },
37+
} = this.props;
3638
const store = this.props.store;
3739
return (
3840
<ThemeProvider theme={options.theme}>

src/components/Redoc/elements.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import styled, { media } from '../../styled-components';
2-
export { ClassAttributes } from 'react';
1+
import { ClassAttributes, HTMLAttributes } from 'react';
2+
3+
import styled, {
4+
media,
5+
ResolvedThemeInterface,
6+
StyledComponentClass,
7+
} from '../../styled-components';
38

49
export const RedocWrap = styled.div`
510
font-family: ${props => props.theme.baseFont.family};

src/components/Responses/styled.elements.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import styled from '../../styled-components';
2-
31
import { transparentize } from 'polished';
2+
import { ClassAttributes, HTMLAttributes } from 'react';
3+
44
import { UnderlinedHeader } from '../../common-elements';
5-
import { ResponseTitle } from './ResponseTitle';
5+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
6+
import { ResponseTitle, ResponseTitleProps } from './ResponseTitle';
67

78
export const StyledResponseTitle = styled(ResponseTitle)`
89
padding: 10px;

src/components/Schema/ObjectSchema.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export class ObjectSchema extends React.Component<ObjectSchemaProps> {
2424
}
2525

2626
render() {
27-
const { schema: { fields = [] }, showTitle, discriminator } = this.props;
27+
const {
28+
schema: { fields = [] },
29+
showTitle,
30+
discriminator,
31+
} = this.props;
2832

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

src/components/Schema/OneOfSchema.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export class OneOfButton extends React.Component<OneOfButtonProps> {
3434
@observer
3535
export class OneOfSchema extends React.Component<SchemaProps> {
3636
render() {
37-
const { schema: { oneOf }, schema } = this.props;
37+
const {
38+
schema: { oneOf },
39+
schema,
40+
} = this.props;
3841

3942
if (oneOf === undefined) {
4043
return null;

src/components/SearchBox/SearchBox.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { MenuItem } from '../SideMenu/MenuItem';
77
import { MarkerService } from '../../services/MarkerService';
88
import { SearchDocument } from '../../services/SearchWorker.worker';
99

10-
import { ClearIcon, SearchIcon, SearchInput, SearchResultsBox, SearchWrap } from './elements';
10+
import {
11+
ClearIcon,
12+
SearchIcon,
13+
SearchInput,
14+
SearchResultsBox,
15+
SearchWrap,
16+
} from './styled.elements';
1117

1218
export interface SearchBoxProps {
1319
search: SearchStore;

src/components/SearchBox/elements.tsx src/components/SearchBox/styled.elements.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
2-
import styled from '../../styled-components';
2+
3+
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components';
34
import { MenuItemLabel } from '../SideMenu/styled.elements';
45

56
export const SearchWrap = styled.div`

src/components/SecurityRequirement/SecuirityRequirement.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { transparentize } from 'polished';
22
import * as React from 'react';
3+
34
import styled from '../../styled-components';
45

56
import { UnderlinedHeader } from '../../common-elements/headers';

src/components/SideMenu/MenuItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IMenuItem, OperationModel } from '../../services';
66
import { MenuItems } from './MenuItems';
77
import { MenuItemLabel, MenuItemLi, MenuItemTitle, OperationBadge } from './styled.elements';
88

9-
interface MenuItemProps {
9+
export interface MenuItemProps {
1010
item: IMenuItem;
1111
onActivate?: (item: IMenuItem) => void;
1212
withoutChildren?: boolean;

src/components/SideMenu/MenuItems.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IMenuItem } from '../../services';
66
import { MenuItem } from './MenuItem';
77
import { MenuItemUl } from './styled.elements';
88

9-
interface MenuItemsProps {
9+
export interface MenuItemsProps {
1010
items: IMenuItem[];
1111
active?: boolean;
1212
onActivate?: (item: IMenuItem) => void;

src/components/SideMenu/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './MenuItem';
2+
export * from './MenuItems';
3+
export * from './SideMenu';
4+
export * from './styled.elements';

0 commit comments

Comments
 (0)