hi-tm 0.1.8 → 0.1.9

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.
@@ -3,6 +3,8 @@ import { TextInputPropsType } from '../../types/Inputs/TextInputType';
3
3
  interface TextInputProps extends TextInputPropsType {
4
4
  applyConditionalStyles?: boolean;
5
5
  maxLength?: number;
6
+ onlyFaChars?: boolean;
7
+ onlyEnChars?: boolean;
6
8
  }
7
- declare const TextInput: ({ label, required, value, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled, type, style, startContent, startContentStyle, placeHolderDirection, applyConditionalStyles, maxLength, }: TextInputProps) => React.JSX.Element;
9
+ declare const TextInput: ({ label, required, value, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled, type, style, startContent, startContentStyle, placeHolderDirection, applyConditionalStyles, maxLength, onlyFaChars, onlyEnChars, }: TextInputProps) => React.JSX.Element;
8
10
  export default TextInput;
@@ -38,7 +38,7 @@ const react_1 = __importStar(require("react"));
38
38
  const TextInput = ({ label, required, value, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled = false, type = 'text', style = {
39
39
  margin: 'mt-[-6px]',
40
40
  width: 'w-full',
41
- }, startContent, startContentStyle, placeHolderDirection = 'ltr', applyConditionalStyles = false, maxLength, }) => {
41
+ }, startContent, startContentStyle, placeHolderDirection = 'ltr', applyConditionalStyles = false, maxLength, onlyFaChars = false, onlyEnChars = false, }) => {
42
42
  const [inputValue, setInputValue] = (0, react_1.useState)('');
43
43
  const inputRef = (0, react_1.useRef)(null);
44
44
  const handleInputChange = (e) => {
@@ -55,6 +55,16 @@ const TextInput = ({ label, required, value, placeholderText, autoComplete, auto
55
55
  newValue = newValue.slice(0, maxLength);
56
56
  e.target.value = newValue;
57
57
  }
58
+ else if (onlyFaChars) {
59
+ // Only allow Persian characters and symbols
60
+ newValue = newValue.replace(/[^\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF\u2000-\u206F\u0020-\u007F]/g, '');
61
+ e.target.value = newValue;
62
+ }
63
+ else if (onlyEnChars) {
64
+ // Only allow English characters and symbols
65
+ newValue = newValue.replace(/[^a-zA-Z0-9\u0020-\u007F]/g, '');
66
+ e.target.value = newValue;
67
+ }
58
68
  setInputValue(newValue);
59
69
  onChangeValueHandler(e);
60
70
  };
@@ -19,4 +19,6 @@ export interface TextInputPropsType {
19
19
  placeHolderDirection?: 'rtl' | 'ltr';
20
20
  applyConditionalStyles?: boolean;
21
21
  maxLength?: number;
22
+ onlyFaChars?: boolean;
23
+ onlyEnChars?: boolean;
22
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {