Skip to content

Commit e463c6d

Browse files
authored
feat: use Parcel for bundling (#36)
* fix: add webstorm config to ignore * feat: use parcel for bundling * fix: remove disable statements
1 parent 0620668 commit e463c6d

File tree

4 files changed

+2260
-502
lines changed

4 files changed

+2260
-502
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ dist
2020
npm-debug.log*
2121
yarn-debug.log*
2222
yarn-error.log*
23+
24+
.idea
25+
.parcel-cache

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "burhanuday",
66
"license": "MIT",
77
"repository": "burhanuday/react-transliterate",
8-
"typings": "./dist/index.d.ts",
8+
"types": "dist/types.d.ts",
99
"keywords": [
1010
"react",
1111
"transliterate",
@@ -18,8 +18,8 @@
1818
"node": ">=10"
1919
},
2020
"scripts": {
21-
"build": "microbundle-crl --no-compress --format modern,cjs",
22-
"start": "microbundle-crl watch --no-compress --format modern,cjs",
21+
"start": "parcel watch",
22+
"build": "parcel build",
2323
"prepare": "run-s build",
2424
"test": "run-s test:unit test:lint test:build",
2525
"test:build": "run-s build",
@@ -34,6 +34,8 @@
3434
"react": "^16.0.0"
3535
},
3636
"devDependencies": {
37+
"@parcel/packager-ts": "^2.0.0",
38+
"@parcel/transformer-typescript-types": "^2.0.0",
3739
"@testing-library/jest-dom": "^5.14.1",
3840
"@testing-library/react": "^12.1.0",
3941
"@testing-library/user-event": "^13.2.1",
@@ -57,9 +59,10 @@
5759
"eslint-plugin-react": "^7.17.0",
5860
"eslint-plugin-standard": "^4.0.1",
5961
"gh-pages": "^2.2.0",
60-
"microbundle-crl": "^0.13.10",
6162
"msw": "^0.35.0",
6263
"npm-run-all": "^4.1.5",
64+
"parcel": "^2.0.0",
65+
"postcss": "^8.2.1",
6366
"prettier": "^2.0.4",
6467
"react": "^17.0.2",
6568
"react-dom": "^17.0.2",

src/index.tsx

+9-14
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ export const ReactTransliterate = ({
2020
lang = "hi",
2121
offsetX = 0,
2222
offsetY = 10,
23-
// eslint-disable-next-line @typescript-eslint/no-empty-function
24-
onChange = () => {},
25-
// eslint-disable-next-line @typescript-eslint/no-empty-function
26-
onChangeText = () => {},
27-
// eslint-disable-next-line @typescript-eslint/no-empty-function
28-
onBlur = () => {},
23+
onChange,
24+
onChangeText,
25+
onBlur,
2926
value,
30-
// eslint-disable-next-line @typescript-eslint/no-empty-function
31-
onKeyDown = () => {},
27+
onKeyDown,
3228
containerClassName = "",
3329
containerStyles = {},
3430
activeItemStyles = {},
@@ -73,7 +69,6 @@ export const ReactTransliterate = ({
7369
const currentString = value;
7470
// create a new string with the currently typed word
7571
// replaced with the word in transliterated language
76-
if (typeof currentString !== "string") return;
7772
const newValue =
7873
currentString.substring(0, matchStart) +
7974
options[index] +
@@ -95,7 +90,7 @@ export const ReactTransliterate = ({
9590
target: { value: newValue },
9691
} as unknown as React.FormEvent<HTMLInputElement>;
9792
onChangeText(newValue);
98-
onChange(e);
93+
onChange && onChange(e);
9994
reset();
10095
return inputRef.current?.focus();
10196
};
@@ -123,7 +118,7 @@ export const ReactTransliterate = ({
123118
const value = e.currentTarget.value;
124119

125120
// bubble up event to the parent component
126-
onChange(e);
121+
onChange && onChange(e);
127122
onChangeText(value);
128123

129124
if (!shouldRenderSuggestions) {
@@ -202,12 +197,12 @@ export const ReactTransliterate = ({
202197
setSelection((selection + 1) % options.length);
203198
break;
204199
default:
205-
onKeyDown(event);
200+
onKeyDown && onKeyDown(event);
206201
break;
207202
}
208203
}
209204
} else {
210-
onKeyDown(event);
205+
onKeyDown && onKeyDown(event);
211206
}
212207
};
213208

@@ -221,7 +216,7 @@ export const ReactTransliterate = ({
221216
reset();
222217
}
223218
}
224-
onBlur(event);
219+
onBlur && onBlur(event);
225220
};
226221

227222
const handleResize = () => {

0 commit comments

Comments
 (0)