Skip to content

Commit

Permalink
update for tsconfig, types and npm config
Browse files Browse the repository at this point in the history
  • Loading branch information
erhangundogan committed Oct 21, 2020
1 parent 1d0aef4 commit 83f7d4b
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 74 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@imagemarker/kveditor",
"version": "0.3.0",
"description": "React key/value UI component library",
"version": "0.4.0",
"description": "React key/value component library",
"repository": "github:imagemarker/kveditor",
"keywords": [
"react",
Expand All @@ -11,7 +11,7 @@
"key-value",
"editor"
],
"types": "types.d.ts",
"types": "./dist/index.d.ts",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand All @@ -20,8 +20,7 @@
"dist",
"package.json",
"LICENSE.md",
"README.md",
"types.d.ts"
"README.md"
],
"scripts": {
"clean": "rimraf dist",
Expand All @@ -32,7 +31,7 @@
"build:prod": "NODE_ENV=production rollup -c rollup.config.js",
"build:example": "yarn clean && NODE_ENV=development rollup -c rollup.examples.config.js",
"start": "yarn build:example && serve dist",
"prepublish": "yarn build"
"prepublishOnly": "yarn build"
},
"devDependencies": {
"@rollup/plugin-html": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/KVEditor/KVEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useReducer } from 'react';
import { KVEditConfigType, KVEditorType, KVItemType } from '@base/types';
import { KVEditConfigType, KVEditorType, KVItemType } from '@base/src/components/KVEditor/KVEditor.types';
import KVReducer from '../../hooks/KVReducer';
import KVItemEdit from '../KVItemEdit/KVItemEdit';
import KVItemView from '../KVItemView/KVItemView';
Expand Down
20 changes: 20 additions & 0 deletions src/components/KVEditor/KVEditor.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ReactElement } from 'react';

export interface KVEditConfigType {
typeNotation?: string;
nested?: boolean;
validateKey?: RegExp;
theme?: string;
}
export interface KVEditorPropsType {
items?: KVItemType[];
options?: KVEditConfigType;
onChange?: (state: any) => void;
}
export interface KVEditorType {
(props: KVEditorPropsType): ReactElement;
}
export interface KVItemType {
key: string;
value: any;
}
2 changes: 1 addition & 1 deletion src/components/KVEditor/__tests__/KVEditor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { KVEditConfigType } from '@base/src/components/KVEditor/KVEditor.types';
import KVReducer from '../../../hooks/KVReducer';
import { KVEditConfigType } from '@base/types';
import KVEditor from '../KVEditor';

jest.mock('../../../hooks/KVReducer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ exports[`KVEditor renders properly 1`] = `
</div>
<input
class="input-submit"
title="Add"
type="submit"
value="Add"
value=""
/>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/components/KVItemEdit/KVItemEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef, useState } from 'react';
import { KVItemEditType } from '@base/types';
import { KVItemEditType } from '@base/src/components/KVItemEdit/KVItemEdit.types';
import './styles.scss';

const KVItemEdit: KVItemEditType = ({ dispatch, keys, editorOptions, item = { key: '', value: '' } }) => {
Expand Down
13 changes: 13 additions & 0 deletions src/components/KVItemEdit/KVItemEdit.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Dispatch, Reducer, ReducerAction } from 'react';
import { KVAction, KVState } from '@base/src/hooks/KVReducer.types';
import { KVEditConfigType, KVItemType } from '@base/src/components/KVEditor/KVEditor.types';

export interface KVItemEditPropsType {
dispatch: Dispatch<ReducerAction<Reducer<KVState, KVAction>>>;
keys: string[];
editorOptions: KVEditConfigType;
item?: KVItemType;
}
export interface KVItemEditType {
(props: KVItemEditPropsType): JSX.Element;
}
2 changes: 1 addition & 1 deletion src/components/KVItemEdit/__tests__/KVItemEdit.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { KVEditConfigType } from '@base/src/components/KVEditor/KVEditor.types';
import KVItemEdit from '../KVItemEdit';
import { KVEditConfigType } from '@base/types';

describe('KVItemEdit', () => {
const validateKey = new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ exports[`KVItemEdit renders properly 1`] = `
</div>
<input
class="input-submit"
title="Add"
type="submit"
value="Add"
value=""
/>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/components/KVItemView/KVItemView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { KVItemViewType } from '@base/types';
import { KVItemViewType } from '@base/src/components/KVItemView/KVItemView.types';
import './styles.scss';

const KVItemView: KVItemViewType = ({ item, dispatch, editorOptions }) => {
Expand Down
13 changes: 13 additions & 0 deletions src/components/KVItemView/KVItemView.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Dispatch, Reducer, ReducerAction } from 'react';
import { KVEditConfigType, KVItemType } from '@base/src/components/KVEditor/KVEditor.types';
import { KVAction, KVState } from '@base/src/hooks/KVReducer.types';

export interface KVItemViewPropsType {
dispatch: Dispatch<ReducerAction<Reducer<KVState, KVAction>>>;
item: KVItemType;
editorOptions: KVEditConfigType;
viewOptions: any;
}
export interface KVItemViewType {
(props: KVItemViewPropsType): JSX.Element;
}
2 changes: 1 addition & 1 deletion src/components/KVItemView/__tests__/KVItemView.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { KVEditConfigType } from '@base/src/components/KVEditor/KVEditor.types';
import KVItemView from '../KVItemView';
import { KVEditConfigType } from '@base/types';

describe('KVItemView', () => {
const validateKey = new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ exports[`KVItemView renders properly 1`] = `
</div>
<input
class="remove"
title="Remove"
type="button"
value="Remove"
/>
</form>
</DocumentFragment>
Expand Down
2 changes: 1 addition & 1 deletion src/example.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
import { KVItemType } from '@base/src/components/KVEditor/KVEditor.types';
import KVEditor from './components/KVEditor/KVEditor';
import { KVItemType } from '@base/types';

const App = () => {
const [darkTheme, setDarkScheme] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/KVReducer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Reducer } from 'react';
import { KVAction, KVState } from '@base/types';
import { KVAction, KVState } from '@base/src/hooks/KVReducer.types';

const KVReducer: Reducer<KVState, KVAction> = (state, action) => {
switch (action.type) {
Expand Down
16 changes: 16 additions & 0 deletions src/hooks/KVReducer.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { KVItemType } from '@base/src/components/KVEditor/KVEditor.types';

export interface KVState {
items: KVItemType[];
keys: string[];
}
export interface KVActionBase {
type: string;
}
export interface KVActionAdd extends KVActionBase {
item?: KVItemType;
}
export interface KVActionRemove extends KVActionBase {
key?: string;
}
export interface KVAction extends KVActionAdd, KVActionRemove {}
2 changes: 1 addition & 1 deletion src/hooks/__tests__/KVReducer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import KVReducer from '../KVReducer';
import { KVState } from '@base/types';
import { KVState } from '@base/src/hooks/KVReducer.types';

describe('KVReducer', () => {
test('ADD works', () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"baseUrl": ".",
"rootDir": "src",
"outDir": "dist",
"declaration": false,
"declaration": true,
"declarationDir": "dist",
"moduleResolution": "Node",
"module": "ESNext",
"target": "ES6",
Expand Down
55 changes: 0 additions & 55 deletions types.d.ts

This file was deleted.

0 comments on commit 83f7d4b

Please sign in to comment.