Skip to content

Commit 5812adb

Browse files
author
k.golikov
committed
Json-To-TypeScript: some changes
1 parent b0c08a5 commit 5812adb

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/pages/jsonToTypeScriptPage/JsonToTypeScriptPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const defaultSelectableConversionOptions: JsonToTypeScriptConversionSelectableOp
3636
exportType: ExportType.ES_MODULE,
3737
isReversedOrder: true,
3838
typeNameTransformer: NameTransformer.PASCAL_CASE,
39-
fieldNameTransformer: NameTransformer.NONE
39+
fieldNameTransformer: NameTransformer.NONE,
40+
isTuplesEnabled: false
4041
};
4142

4243
const nameTransformers: Readonly<Record<NameTransformer, (name: string) => string>> = {

src/pages/jsonToTypeScriptPage/components/JsonToTypeScriptSettings.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Dispatch, FunctionComponent, SetStateAction } from 'react';
22
import JsonToTypeScriptConversionSelectableOptions, {
33
NameTransformer
44
} from '../types/JsonToTypeScriptConversionSelectableOptions';
5-
import { Button, Col, Input, Select, Switch } from 'antd';
5+
import { Button, Col, Input, Select, Switch, Tooltip } from 'antd';
66
import useChangeStateHandler from '../../../hooks/useChangeStateHandler';
77
import styles from './JsonToTypeScriptSettings.module.scss';
88
import ExportType from '../types/ExportType';
@@ -86,6 +86,16 @@ const JsonToTypeScriptSettings: FunctionComponent<Props> = ({ options, setOption
8686
<Switch checked={options.isReversedOrder} onChange={handleOptionChange('isReversedOrder')} />
8787
<span className="ms-3">Reverse declarations</span>
8888
</label>
89+
90+
<label className={classNames('mt-1', styles.formItem)}>
91+
<Switch checked={options.isTuplesEnabled} onChange={handleOptionChange('isTuplesEnabled')} disabled />
92+
<Tooltip title="Coming soon" placement="bottom">
93+
<Text className="ms-3" type="secondary">
94+
Enable tuples
95+
{/*<Text italic type="secondary" className="ms-2">Coming soon</Text>*/}
96+
</Text>
97+
</Tooltip>
98+
</label>
8999
</Col>
90100
);
91101
};

src/pages/jsonToTypeScriptPage/types/JsonToTypeScriptConversionOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface JsonToTypeScriptConversionOptions {
66
fieldNameTransformer?: (fieldName: string) => string;
77
typeNameTransformer?: (typeName: string) => string;
88
rootTypeName: string;
9+
isTuplesEnabled?: boolean;
910
}
1011

1112
export default JsonToTypeScriptConversionOptions;
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ExportType from './ExportType';
1+
import JsonToTypeScriptConversionOptions from './JsonToTypeScriptConversionOptions';
22

33
export enum NameTransformer {
44
NONE = 'NONE',
@@ -9,12 +9,10 @@ export enum NameTransformer {
99
KEBAB_CASE = 'KEBAB_CASE'
1010
}
1111

12-
interface JsonToTypeScriptConversionSelectableOptions {
13-
exportType: ExportType;
14-
isReversedOrder: boolean;
12+
interface JsonToTypeScriptConversionSelectableOptions
13+
extends Required<Omit<JsonToTypeScriptConversionOptions, 'typeNameTransformer' | 'fieldNameTransformer'>> {
1514
fieldNameTransformer: NameTransformer;
1615
typeNameTransformer: NameTransformer;
17-
rootTypeName: string;
1816
}
1917

2018
export default JsonToTypeScriptConversionSelectableOptions;

0 commit comments

Comments
 (0)