@modul/mbui 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@modul/mbui",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "packageManager": "yarn@3.5.1",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "build:demo": "webpack --config ./demo/webpack.config.js",
8
+ "dev:demo": "webpack serve --config ./demo/webpack.config.js --open",
8
9
  "demo": "yarn dlx http-server demo/dist -so -c-1"
9
10
  },
10
11
  "lintConfig": "./.eslintrc.json",
@@ -12,7 +13,8 @@
12
13
  "src"
13
14
  ],
14
15
  "dependencies": {
15
- "react-datepicker": "4.16.0"
16
+ "react-datepicker": "4.16.0",
17
+ "react-imask": "7.1.3"
16
18
  },
17
19
  "devDependencies": {
18
20
  "@babel/core": "^7.9.0",
@@ -52,7 +54,8 @@
52
54
  "tslib": "^2.5.0",
53
55
  "typescript": "4.4.4",
54
56
  "webpack": "^5.82.1",
55
- "webpack-cli": "^5.1.1"
57
+ "webpack-cli": "^5.1.1",
58
+ "webpack-dev-server": "4.15.1"
56
59
  },
57
60
  "peerDependencies": {
58
61
  "classnames": "^2.3.2",
@@ -0,0 +1,22 @@
1
+ import React, { ChangeEvent, ForwardedRef } from 'react'
2
+ import { IMaskInput } from 'react-imask'
3
+ import { IInputProps } from './types'
4
+
5
+ const Input = React.forwardRef<HTMLInputElement, IInputProps>(
6
+ ({ onChange, ...props }: IInputProps, ref: ForwardedRef<HTMLInputElement>) => {
7
+ const handleChange = (event: ChangeEvent<HTMLInputElement>): void => {
8
+ const val = event.target.value
9
+ onChange?.(val, event)
10
+ }
11
+
12
+ return (
13
+ <IMaskInput
14
+ ref={ref}
15
+ {...props}
16
+ onChange={handleChange}
17
+ />
18
+ )
19
+ }
20
+ )
21
+
22
+ export default Input
@@ -0,0 +1,3 @@
1
+ import Input from './Input'
2
+
3
+ export { Input }
@@ -0,0 +1,10 @@
1
+ import React, { ChangeEvent, ChangeEventHandler } from 'react'
2
+
3
+ type CustomChangeEventHandler = (value: string, event: ChangeEvent<HTMLInputElement>) => void
4
+
5
+ type CombinedChangeEventHandler = ChangeEventHandler<HTMLInputElement> & CustomChangeEventHandler
6
+
7
+ export interface IInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
8
+ onChange?: CombinedChangeEventHandler
9
+ mask?: string | RegExp | (string | RegExp)[]
10
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Button } from './Base/Buttons'
2
2
  import { TextLink } from './Base/Links'
3
3
  import { DatePicker } from './DatePicker'
4
+ import { Input } from './Base/Input'
4
5
 
5
- export { Button, TextLink, DatePicker }
6
+ export { Button, TextLink, DatePicker, Input }