Skip to content

Commit 783d675

Browse files
committed
Merge branch 'develop'
2 parents 6826429 + 08ff4b3 commit 783d675

File tree

6 files changed

+712
-778
lines changed

6 files changed

+712
-778
lines changed

jest.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ module.exports = {
3636
https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object */
3737
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }],
3838
},
39-
transformIgnorePatterns: [
40-
'^.+\\.module\\.(css|sass|scss)$',
41-
],
39+
transformIgnorePatterns: ['^.+\\.module\\.(css|sass|scss)$'],
4240
testPathIgnorePatterns: ['_helpers.tsx'],
4341
}

locales/en/domain-convert-outputs-sqlOutput.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
"dialect_redshift": "Redshift",
1212
"dialect_spark": "Spark",
1313
"dialect_sql": "SQL",
14+
"dialect_sqlite": "SQLite",
1415
"dialect_tsql": "T-SQL",
15-
"indent_label": "Indentation",
16+
"keyword_case_label": "Keyword Case",
17+
"keyword_lower_case_option": "Lower",
18+
"keyword_upper_case_option": "Upper",
1619
"language_label": "SQL Dialect",
17-
"upper_case_label": "Upper Case"
20+
"tab_width_label": "Indentation"
1821
}

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@
2424
"bluebird": "^3.7.2",
2525
"chrono-node": "^2.3.8",
2626
"crypto-js": "^4.1.1",
27-
"dayjs": "^1.11.1",
27+
"dayjs": "^1.11.2",
2828
"diff": "^5.0.0",
29-
"evergreen-ui": "^6.9.9",
29+
"evergreen-ui": "^6.9.10",
3030
"fast-xml-parser": "^4.0.7",
3131
"hjson": "^3.2.2",
3232
"js-base64": "^3.7.2",
3333
"js-yaml": "^4.1.0",
3434
"jsonwebtoken": "^8.5.1",
3535
"lodash": "^4.17.21",
36-
"next": "12.1.5",
36+
"next": "12.1.6",
3737
"next-translate": "^1.4.0",
3838
"papaparse": "^5.3.2",
3939
"prettier": "^2.6.2",
4040
"prismjs": "^1.28.0",
4141
"react": "17.0.2",
4242
"react-dom": "17.0.2",
43-
"react-responsive": "^9.0.0-beta.6",
43+
"react-responsive": "^9.0.0-beta.8",
4444
"showdown": "^2.1.0",
45-
"sql-formatter": "^4.0.2",
45+
"sql-formatter": "^6.1.1",
4646
"uuid": "^8.3.2"
4747
},
4848
"devDependencies": {
49-
"@commitlint/cli": "^16.2.4",
50-
"@commitlint/config-conventional": "^16.2.4",
49+
"@commitlint/cli": "^17.0.0",
50+
"@commitlint/config-conventional": "^17.0.0",
5151
"@compiled/webpack-loader": "^0.8.7",
5252
"@semantic-release/changelog": "^6.0.1",
5353
"@semantic-release/commit-analyzer": "^9.0.2",
@@ -65,29 +65,29 @@
6565
"@types/json2csv": "^5.0.3",
6666
"@types/jsonwebtoken": "^8.5.8",
6767
"@types/lodash": "^4.14.182",
68-
"@types/node": "^17.0.31",
68+
"@types/node": "^17.0.34",
6969
"@types/papaparse": "^5.3.2",
7070
"@types/prismjs": "^1.26.0",
71-
"@types/react": "18.0.8",
71+
"@types/react": "18.0.9",
7272
"@types/showdown": "^2.0.0",
7373
"@types/uuid": "^8.3.4",
74-
"@typescript-eslint/eslint-plugin": "^5.22.0",
75-
"@typescript-eslint/parser": "^5.22.0",
76-
"babel-jest": "^28.0.3",
74+
"@typescript-eslint/eslint-plugin": "^5.24.0",
75+
"@typescript-eslint/parser": "^5.24.0",
76+
"babel-jest": "^28.1.0",
7777
"babel-plugin-import": "^1.13.5",
7878
"babel-plugin-module-resolver": "^4.1.0",
79-
"eslint": "^8.14.0",
79+
"eslint": "^8.15.0",
8080
"eslint-config-airbnb": "^19.0.4",
81-
"eslint-config-next": "^12.1.5",
81+
"eslint-config-next": "^12.1.6",
8282
"eslint-config-prettier": "^8.5.0",
8383
"eslint-import-resolver-typescript": "^2.7.1",
8484
"eslint-plugin-jsx-a11y": "^6.5.1",
8585
"eslint-plugin-react-hooks": "^4.5.0",
8686
"eslint-plugin-tsdoc": "^0.2.16",
87-
"husky": "^7.0.4",
87+
"husky": "^8.0.1",
8888
"identity-obj-proxy": "^3.0.0",
89-
"jest": "^28.0.3",
90-
"jest-environment-jsdom": "^28.0.2",
89+
"jest": "^28.1.0",
90+
"jest-environment-jsdom": "^28.1.0",
9191
"react-test-renderer": "^17.0.2",
9292
"semantic-release": "^19.0.2",
9393
"typescript": "4.6.4"

src/components/domain/convert/outputs/SqlOutput.tsx

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ChangeEvent, forwardRef } from 'react'
2-
import { Checkbox, Select, majorScale } from 'evergreen-ui'
1+
import { ChangeEvent, forwardRef, useState } from 'react'
2+
import { Select, majorScale } from 'evergreen-ui'
33
import useTranslation from 'next-translate/useTranslation'
44

55
import { Form, Label, SqlTextarea } from '@components/forms'
@@ -19,6 +19,7 @@ const dialects = [
1919
'redshift',
2020
'spark',
2121
'sql',
22+
'sqlite',
2223
'tsql',
2324
]
2425

@@ -37,14 +38,21 @@ export const SqlOutput = forwardRef<HTMLTextAreaElement, OutputProps>(
3738
const { options, setOptions } = useConverterOptionsContext(
3839
converter.outputId,
3940
)
41+
const [space, setSpace] = useState(
42+
(options.useTabs ? '\t' : ' ').repeat(options.tabWidth as number),
43+
)
4044

4145
/**
42-
* Updates the output options state when the indent dropdown is changed.
46+
* Updates the output options state when the tabWidth dropdown is changed.
4347
*
4448
* @param event - the HTML select change event.
4549
*/
46-
const onChangeIndent = (event: ChangeEvent<HTMLSelectElement>) => {
47-
setOptions({ ...options, indent: event.target.value })
50+
const onChangeTabWidth = (event: ChangeEvent<HTMLSelectElement>) => {
51+
const spc = event.target.value
52+
const useTabs = spc[0] === '\t'
53+
const tabWidth = spc.split('').length
54+
setOptions({ ...options, tabWidth, useTabs })
55+
setSpace(event.target.value)
4856
}
4957

5058
/**
@@ -57,19 +65,19 @@ export const SqlOutput = forwardRef<HTMLTextAreaElement, OutputProps>(
5765
}
5866

5967
/**
60-
* Updates the output options state when the upper-case checkbox is changed.
68+
* Updates the output options state when the keyword-case dropdown is changed.
6169
*
62-
* @param event - the HTML checkbox change event.
70+
* @param event - the HTML select change event.
6371
*/
64-
const onChangeUpperCase = (event: ChangeEvent<HTMLInputElement>) => {
65-
setOptions({ ...options, uppercase: event.target.checked })
72+
const onChangeKeywordCase = (event: ChangeEvent<HTMLSelectElement>) => {
73+
setOptions({ ...options, keywordCase: event.target.value })
6674
}
6775

6876
return (
6977
<Form>
7078
<Label
7179
disabled={disabled}
72-
htmlFor="indentInput"
80+
htmlFor="languageInput"
7381
label={t('language_label')}
7482
>
7583
<Select
@@ -89,15 +97,15 @@ export const SqlOutput = forwardRef<HTMLTextAreaElement, OutputProps>(
8997

9098
<Label
9199
disabled={disabled}
92-
htmlFor="indentInput"
93-
label={t('indent_label')}
100+
htmlFor="tabWidthInput"
101+
label={t('tab_width_label')}
94102
>
95103
<Select
96104
disabled={disabled}
97-
id="indentInput"
105+
id="tabWidthInput"
98106
maxWidth={majorScale(15)}
99-
onChange={onChangeIndent}
100-
value={options.indent as string}
107+
onChange={onChangeTabWidth}
108+
value={space}
101109
>
102110
<option value={' '}>{t('2_spaces_option')}</option>
103111
<option value={' '}>{t('4_spaces_option')}</option>
@@ -107,15 +115,19 @@ export const SqlOutput = forwardRef<HTMLTextAreaElement, OutputProps>(
107115

108116
<Label
109117
disabled={disabled}
110-
htmlFor="upperCaseInput"
111-
label={t('upper_case_label')}
118+
htmlFor="keywordCaseInput"
119+
label={t('keyword_case_label')}
112120
>
113-
<Checkbox
114-
checked={options.uppercase as boolean}
121+
<Select
115122
disabled={disabled}
116-
id="upperCaseInput"
117-
onChange={onChangeUpperCase}
118-
/>
123+
id="keywordCaseInput"
124+
maxWidth={majorScale(15)}
125+
onChange={onChangeKeywordCase}
126+
value={options.keywordCase as string}
127+
>
128+
<option value={'upper'}>{t('keyword_upper_case_option')}</option>
129+
<option value={'lower'}>{t('keyword_lower_case_option')}</option>
130+
</Select>
119131
</Label>
120132

121133
<SqlTextarea

src/lib/outputs/SqlOutput.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import type { ConverterOptions } from '@lib/types'
77
* if no user-defined options were provided.
88
*/
99
export const defaultOptions = {
10-
indent: ' ',
10+
keywordCase: 'upper',
1111
language: 'sql',
12-
uppercase: true,
12+
tabWidth: 2,
13+
useTabs: false,
1314
}
1415

1516
/**
@@ -32,5 +33,5 @@ export const output = (
3233
return format(input, {
3334
...defaultOptions,
3435
...options,
35-
} as FormatOptions)
36+
} as unknown as FormatOptions)
3637
}

0 commit comments

Comments
 (0)