Skip to content

Commit

Permalink
fix typescript support in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MostafaRostami72 committed Oct 31, 2021
1 parent a67f4cf commit c7d19e4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Full Document and Demo
- [Document And Demo](https://mostafarostami72.github.io/react-selection-box/)

### ** Supports typescript **

## Install

Expand Down
2 changes: 2 additions & 0 deletions example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "nprogress/nprogress.css";
const Home = lazy(() => import('./pages/home'));
const BasicUsage = lazy(() => import('./pages/basic_usage'));
const Examples = lazy(() => import('./pages/examples'));
const TypescriptPage = lazy(() => import('./pages/typescript'));
const PropsPage = lazy(() => import('./pages/props'));
const Styles = lazy(() => import('./pages/styles'));

Expand Down Expand Up @@ -69,6 +70,7 @@ const App = () => {
<Switch>
<Route path="/react-selection-box/basic_usage" exact component={BasicUsage}/>
<Route path="/react-selection-box/examples" exact component={Examples}/>
<Route path="/react-selection-box/typescript" exact component={TypescriptPage}/>
<Route path="/react-selection-box/props" exact component={PropsPage}/>
<Route path="/react-selection-box/styles" exact component={Styles}/>
<Route path="/react-selection-box/" component={Home}/>
Expand Down
8 changes: 7 additions & 1 deletion example/src/components/includes/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {Link} from "react-router-dom";
import {useLocation} from "react-router-dom";
import {DocumentTextIcon, ChevronRightIcon, CubeIcon, CursorClickIcon, KeyIcon, PhotographIcon} from '@heroicons/react/outline'
import {DocumentTextIcon, ChevronRightIcon, CubeIcon, CursorClickIcon, KeyIcon, PhotographIcon, BeakerIcon} from '@heroicons/react/outline'

const Sidebar = () => {
const location = useLocation();
Expand All @@ -27,6 +27,12 @@ const Sidebar = () => {
active: (pathname === '/react-selection-box/examples'),
icon: DocumentTextIcon
},
{
link: '/react-selection-box/typescript',
title: 'Typescript',
active: (pathname === '/react-selection-box/typescript'),
icon: BeakerIcon
},
{
link: '/react-selection-box/props',
title: 'Props',
Expand Down
30 changes: 30 additions & 0 deletions example/src/pages/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import Code from "../components/code";

const TypescriptPage = () => {
return (
<div className="my-3">
<h2 className="">Supports typescript</h2>
<p className="">
You can use <span className="bg-info px-1 font-weight-500">react-selection-box</span> in your typescript projects
</p>

<Code className="mt-3">
{
`
import Selection, {
IReactSelectionBoxProps,
ITypes,
IOptions,
IDefaultSelectedRange,
ITranslates
} from 'react-selection-box';
import 'react-selection-box/dist/index.css'
`
}
</Code>
</div>
);
};

export default React.memo(TypescriptPage);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-selection-box",
"version": "1.0.2",
"version": "1.1.3",
"description": "A beautiful and responsive Select Input control for ReactJS with singleselect, multiselect, rangeselect and autocomplete (async) support.",
"author": "MostafaRostami72",
"license": "MIT",
Expand Down
14 changes: 7 additions & 7 deletions react-selection-box.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import * as React from 'react';

type ITypes = 'single' | 'multiple' | 'range'
export type ITypes = 'single' | 'multiple' | 'range'

interface IOptions {
export interface IOptions {
value: number | string
label: number | string
checked: boolean
}

interface IValueAnsLabelShape {
interface IValueAndLabelShape {
value: number | string
label: number | string
}

interface IDefaultSelectedRange {
min?: IValueAnsLabelShape,
max?: IValueAnsLabelShape
export interface IDefaultSelectedRange {
min?: IValueAndLabelShape,
max?: IValueAndLabelShape
}

interface ITranslates {
export interface ITranslates {
label?: {
from: string,
to: string
Expand Down

0 comments on commit c7d19e4

Please sign in to comment.