persian-number-input 3.0.8 → 3.0.10
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
CHANGED
|
@@ -27,6 +27,8 @@ Easily input, format, and convert numbers in Persian, English, or Indic digits w
|
|
|
27
27
|
npm install persian-number-input
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+

|
|
31
|
+
|
|
30
32
|
### 💻 Usage Example
|
|
31
33
|
|
|
32
34
|
Simple usage example:
|
|
@@ -59,7 +61,7 @@ Displayed Output: ۱۲۳,۴۵۶
|
|
|
59
61
|
English Output: 123456
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-

|
|
63
65
|
|
|
64
66
|
### 📚 Props Reference
|
|
65
67
|
|
|
@@ -159,6 +161,8 @@ export default App;
|
|
|
159
161
|
خروجی انگلیسی: 123456
|
|
160
162
|
```
|
|
161
163
|
|
|
164
|
+

|
|
165
|
+
|
|
162
166
|
### 📚 مشخصات Props
|
|
163
167
|
|
|
164
168
|
| نام | نوع | پیشفرض | توضیح |
|
|
@@ -9,7 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useCallback } from 'react';
|
|
12
|
+
import React, { useCallback, useState } from 'react';
|
|
13
|
+
import PropTypes from 'prop-types'; // اضافه کردن PropTypes برای تایپدهی در زمان اجرا
|
|
13
14
|
import { toLocalizedDigits, groupDigits, convertToEnglishDigits } from '../utils/digitUtils';
|
|
14
15
|
// استایل پایه برای input
|
|
15
16
|
const baseInputStyle = {
|
|
@@ -18,7 +19,7 @@ const baseInputStyle = {
|
|
|
18
19
|
};
|
|
19
20
|
const PersianNumberInput = (_a) => {
|
|
20
21
|
var { initialValue = '', separatorCount = 0, separatorChar = ',', lang = 'fa', onChangeValue, style } = _a, rest = __rest(_a, ["initialValue", "separatorCount", "separatorChar", "lang", "onChangeValue", "style"]);
|
|
21
|
-
const [value, setValue] =
|
|
22
|
+
const [value, setValue] = useState(() => convertToEnglishDigits(initialValue).replace(/\D/g, ''));
|
|
22
23
|
const handleChange = useCallback((e) => {
|
|
23
24
|
const input = convertToEnglishDigits(e.target.value).replace(/\D/g, '');
|
|
24
25
|
setValue(input);
|
|
@@ -28,7 +29,16 @@ const PersianNumberInput = (_a) => {
|
|
|
28
29
|
const formattedValue = groupDigits(value, separatorCount, separatorChar);
|
|
29
30
|
const displayValue = lang === 'en' ? formattedValue : toLocalizedDigits(formattedValue, lang);
|
|
30
31
|
const mergedStyle = Object.assign(Object.assign({}, baseInputStyle), style);
|
|
31
|
-
return React.createElement("input", Object.assign({ value: displayValue, onChange: handleChange, style: mergedStyle }, rest));
|
|
32
|
+
return (React.createElement("input", Object.assign({ value: displayValue, onChange: handleChange, style: mergedStyle }, rest)));
|
|
33
|
+
};
|
|
34
|
+
// اضافه کردن PropTypes برای اطمینان از تطابق نوع
|
|
35
|
+
PersianNumberInput.propTypes = {
|
|
36
|
+
initialValue: PropTypes.string,
|
|
37
|
+
separatorCount: PropTypes.number,
|
|
38
|
+
separatorChar: PropTypes.string,
|
|
39
|
+
lang: PropTypes.oneOf(['fa', 'in', 'en']),
|
|
40
|
+
onChangeValue: PropTypes.func,
|
|
41
|
+
style: PropTypes.object,
|
|
32
42
|
};
|
|
33
43
|
export default PersianNumberInput;
|
|
34
44
|
//# sourceMappingURL=PersianNumberInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersianNumberInput.js","sourceRoot":"","sources":["../../src/components/PersianNumberInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PersianNumberInput.js","sourceRoot":"","sources":["../../src/components/PersianNumberInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAA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R,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;KACT,CAAC;IACF,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,48 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "persian-number-input",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "React component for Persian, Indic, or English localized number input with customizable digit grouping",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"typings": "dist/index.d.ts",
|
|
9
|
-
"sideEffects": false,
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
15
|
-
"prepublishOnly": "npm run build",
|
|
16
|
-
"test": "jest"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"react",
|
|
20
|
-
"persian",
|
|
21
|
-
"indic",
|
|
22
|
-
"number",
|
|
23
|
-
"input",
|
|
24
|
-
"localization",
|
|
25
|
-
"digit-grouping"
|
|
26
|
-
],
|
|
27
|
-
"author": "Your Name",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "https://github.com/javadSharifi/persian-number-input"
|
|
32
|
-
},
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/javadSharifi/persian-number-input/issues"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://github.com/javadSharifi/persian-number-input#readme",
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"react": "^16.8 || ^17 || ^18 || ^19"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/
|
|
42
|
-
"@types/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"ts-jest": "^29.
|
|
47
|
-
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "persian-number-input",
|
|
3
|
+
"version": "3.0.10",
|
|
4
|
+
"description": "React component for Persian, Indic, or English localized number input with customizable digit grouping",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"typings": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"test": "jest"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react",
|
|
20
|
+
"persian",
|
|
21
|
+
"indic",
|
|
22
|
+
"number",
|
|
23
|
+
"input",
|
|
24
|
+
"localization",
|
|
25
|
+
"digit-grouping"
|
|
26
|
+
],
|
|
27
|
+
"author": "Your Name",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/javadSharifi/persian-number-input"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/javadSharifi/persian-number-input/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/javadSharifi/persian-number-input#readme",
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^16.8 || ^17 || ^18 || ^19"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/jest": "^29.5.14",
|
|
42
|
+
"@types/prop-types": "^15.7.14",
|
|
43
|
+
"@types/react": "^19.1.2",
|
|
44
|
+
"@types/react-dom": "^19.1.2",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"ts-jest": "^29.3.2",
|
|
47
|
+
"typescript": "^5.8.3"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"prop-types": "^15.8.1"
|
|
51
|
+
}
|
|
52
|
+
}
|