numora-react 1.0.0 → 1.0.2
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/README.md +289 -47
- package/dist/index.cjs.js +71 -434
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +16 -7
- package/dist/index.esm.js +65 -435
- package/dist/index.esm.js.map +1 -1
- package/package.json +17 -7
- package/dist/types/index.d.ts +0 -2
- package/rollup.config.mjs +0 -38
- package/src/index.tsx +0 -50
- package/tsconfig.json +0 -18
package/rollup.config.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
-
import babel from '@rollup/plugin-babel';
|
|
4
|
-
import typescript from '@rollup/plugin-typescript';
|
|
5
|
-
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
6
|
-
import packageJson from './package.json' assert { type: 'json' };
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
input: 'src/index.tsx',
|
|
10
|
-
output: [
|
|
11
|
-
{
|
|
12
|
-
file: packageJson.main,
|
|
13
|
-
format: 'cjs',
|
|
14
|
-
sourcemap: true,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
file: packageJson.module,
|
|
18
|
-
format: 'esm',
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
plugins: [
|
|
23
|
-
peerDepsExternal(),
|
|
24
|
-
resolve(),
|
|
25
|
-
commonjs(),
|
|
26
|
-
typescript({ tsconfig: './tsconfig.json' }),
|
|
27
|
-
babel({
|
|
28
|
-
exclude: 'node_modules/**',
|
|
29
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
30
|
-
babelHelpers: 'bundled',
|
|
31
|
-
presets: [
|
|
32
|
-
['@babel/preset-env', { targets: 'defaults' }],
|
|
33
|
-
['@babel/preset-react', { runtime: 'automatic' }],
|
|
34
|
-
],
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
37
|
-
external: ['react', 'react-dom', 'numora'],
|
|
38
|
-
};
|
package/src/index.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ChangeEvent, ClipboardEvent, forwardRef } from 'react';
|
|
2
|
-
import { handleOnChangeNumericInput, handleOnPasteNumericInput } from 'numora';
|
|
3
|
-
|
|
4
|
-
interface NumericInputProps {
|
|
5
|
-
additionalStyle?: string;
|
|
6
|
-
maxDecimals?: number;
|
|
7
|
-
defaultValue?: string;
|
|
8
|
-
autoFocus?: boolean;
|
|
9
|
-
onChange?: (e: ChangeEvent<HTMLInputElement> | ClipboardEvent<HTMLInputElement>) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const DEFAULT_PROPS = {
|
|
13
|
-
autoComplete: 'off',
|
|
14
|
-
autoCorrect: 'off',
|
|
15
|
-
autoCapitalize: 'none',
|
|
16
|
-
minLength: 1,
|
|
17
|
-
placeholder: '0.0',
|
|
18
|
-
pattern: '^[0-9]*[.,]?[0-9]*$',
|
|
19
|
-
spellCheck: false,
|
|
20
|
-
step: 'any',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const NumericInput = forwardRef<HTMLInputElement, NumericInputProps>(
|
|
24
|
-
({ maxDecimals = 2, onChange, ...props }: NumericInputProps) => {
|
|
25
|
-
function handleOnChange(e: ChangeEvent<HTMLInputElement>): void {
|
|
26
|
-
handleOnChangeNumericInput(e.nativeEvent, maxDecimals);
|
|
27
|
-
if (onChange) onChange(e);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function handleOnPaste(e: ClipboardEvent<HTMLInputElement>): void {
|
|
31
|
-
handleOnPasteNumericInput(e.nativeEvent, maxDecimals);
|
|
32
|
-
if (onChange) onChange(e);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<input
|
|
37
|
-
{...DEFAULT_PROPS}
|
|
38
|
-
{...props}
|
|
39
|
-
onChange={handleOnChange}
|
|
40
|
-
onPaste={handleOnPaste}
|
|
41
|
-
type="text"
|
|
42
|
-
inputMode="decimal"
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
NumericInput.displayName = 'NumericInput';
|
|
49
|
-
|
|
50
|
-
export { NumericInput };
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"jsx": "react-jsx",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"lib": ["ESNext", "DOM"]
|
|
15
|
-
},
|
|
16
|
-
"include": ["src/**/*"],
|
|
17
|
-
"exclude": ["node_modules", "dist"]
|
|
18
|
-
}
|