hi-tm 0.2.2 → 0.2.4
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/dist/components/Inputs/InputCurrency.d.ts +2 -2
- package/dist/components/Inputs/InputCurrency.js +16 -10
- package/dist/components/Inputs/TextInput.js +0 -3
- package/dist/components/Table/ModernTable/ModernTable.js +1 -1
- package/dist/types/DropDown/DropDownType.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InputCurrencyPropsType } from
|
|
2
|
-
import React from
|
|
1
|
+
import { InputCurrencyPropsType } from "../../types/Inputs/InputCurrencyType";
|
|
2
|
+
import React from "react";
|
|
3
3
|
/**
|
|
4
4
|
* InputCurrency Component
|
|
5
5
|
* A controlled input field for currency values, supporting Persian and English numerals,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -57,7 +57,7 @@ const react_1 = __importStar(require("react"));
|
|
|
57
57
|
* @returns React.JSX.Element
|
|
58
58
|
*/
|
|
59
59
|
const InputCurrency = ({ placeholder, value, required, currencyUnit, textError, label, autoComplete, autoFocus, inlineCss, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled = false, }) => {
|
|
60
|
-
const [inputValue, setInputValue] = (0, react_1.useState)(value?.toString() ||
|
|
60
|
+
const [inputValue, setInputValue] = (0, react_1.useState)(value?.toString() || "");
|
|
61
61
|
const inputRef = (0, react_1.useRef)(null);
|
|
62
62
|
(0, react_1.useEffect)(() => {
|
|
63
63
|
if (value !== null) {
|
|
@@ -72,17 +72,23 @@ const InputCurrency = ({ placeholder, value, required, currencyUnit, textError,
|
|
|
72
72
|
}
|
|
73
73
|
}, [value]);
|
|
74
74
|
const isErrorVisible = () => {
|
|
75
|
-
return !(textError && textError.trim() !==
|
|
75
|
+
return !(textError && textError.trim() !== "");
|
|
76
76
|
};
|
|
77
77
|
const handleChange = (event) => {
|
|
78
78
|
const newValue = event.target.value;
|
|
79
79
|
// Being allowed to enter Persian numbers
|
|
80
|
-
const validValue = newValue.replace(/[^\d۰-۹]/g,
|
|
80
|
+
const validValue = newValue.replace(/[^\d۰-۹]/g, "");
|
|
81
81
|
setInputValue(validValue);
|
|
82
82
|
onChangeValueHandler(event);
|
|
83
83
|
};
|
|
84
84
|
const handleKeyDown = (event) => {
|
|
85
|
-
const allowedKeys = [
|
|
85
|
+
const allowedKeys = [
|
|
86
|
+
"Backspace",
|
|
87
|
+
"ArrowLeft",
|
|
88
|
+
"ArrowRight",
|
|
89
|
+
"Delete",
|
|
90
|
+
"Tab",
|
|
91
|
+
];
|
|
86
92
|
const isNumber = /[0-9۰-۹]/.test(event.key);
|
|
87
93
|
if (!isNumber && !allowedKeys.includes(event.key)) {
|
|
88
94
|
event.preventDefault();
|
|
@@ -94,12 +100,12 @@ const InputCurrency = ({ placeholder, value, required, currencyUnit, textError,
|
|
|
94
100
|
react_1.default.createElement("div", { className: "w-full relative", style: inlineCss },
|
|
95
101
|
react_1.default.createElement("label", { htmlFor: label, className: "flex items-center gap-2 mx-3" },
|
|
96
102
|
react_1.default.createElement("p", { className: "text-sm text-text-color-primary font-medium cursor-pointer" }, label),
|
|
97
|
-
react_1.default.createElement("span", { className: `text-red-primary ${required ?
|
|
103
|
+
react_1.default.createElement("span", { className: `text-red-primary ${required ? "opacity-100" : "opacity-0"} ` }, "*")),
|
|
98
104
|
react_1.default.createElement("div", { className: `w-full h-9 flex items-center justify-between bg-inherit outline-none border rounded-lg text-sm px-2 ${isErrorVisible()
|
|
99
|
-
?
|
|
100
|
-
:
|
|
101
|
-
react_1.default.createElement("input", { ref: inputRef, type: "text", id: label, disabled: disabled, value: Number(inputValue).toLocaleString(), placeholder: placeholder, autoComplete: autoComplete ?
|
|
105
|
+
? "border-gray-tertiary focus:border-gray-quaternary"
|
|
106
|
+
: "border-red-primary"}` },
|
|
107
|
+
react_1.default.createElement("input", { ref: inputRef, type: "text", id: label, disabled: disabled, value: Number(inputValue).toLocaleString(), placeholder: placeholder, autoComplete: autoComplete ? "on" : "off", autoFocus: autoFocus, onChange: handleChange, onBlur: onBlurHandler, onFocus: onFocusHandler, onKeyUp: onKeyUpHandler, onKeyDown: handleKeyDown, className: "outline-none bg-inherit w-full h-full", required: required }),
|
|
102
108
|
react_1.default.createElement("p", { className: "text-sm text-text-color-primary border-r border-gray-tertiary px-2" }, currencyUnit)),
|
|
103
|
-
!isErrorVisible() && react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim()))));
|
|
109
|
+
!isErrorVisible() && (react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim())))));
|
|
104
110
|
};
|
|
105
111
|
exports.default = InputCurrency;
|
|
@@ -191,9 +191,6 @@ const TextInput = ({ label, required, value, placeholderText, autoComplete, auto
|
|
|
191
191
|
if (detectKeyboardLanguage && onKeyboardLanguageChange) {
|
|
192
192
|
// Try to detect from the key pressed
|
|
193
193
|
const key = e.key;
|
|
194
|
-
const code = e.code;
|
|
195
|
-
// Log for debugging (you can remove this later)
|
|
196
|
-
console.log('Key pressed:', key, 'Code:', code, 'Event:', e.nativeEvent);
|
|
197
194
|
// Check if the key is a Persian character
|
|
198
195
|
if (/[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(key)) {
|
|
199
196
|
onKeyboardLanguageChange('fa');
|
|
@@ -203,7 +203,7 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
203
203
|
if (item.onClick) {
|
|
204
204
|
item.onClick(item.id);
|
|
205
205
|
}
|
|
206
|
-
}, className: "flex items-center gap-2 w-full" }, item.hasImage ? (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full" },
|
|
206
|
+
}, className: "flex items-center gap-2 w-full" }, item.hasImage && item.imageUrl !== null ? (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full" },
|
|
207
207
|
react_1.default.createElement(SafeImage_1.default, { src: item.imageUrl || '/defaultImage.jpg', alt: item.value?.toString() || 'Table item', width: item.imageWidth || 24, height: item.imageHeight || 24, className: item.imageClass || 'h-6 w-6 object-cover' }),
|
|
208
208
|
react_1.default.createElement("p", { className: `${item.contentClass || 'text-start'} text-sm w-full truncate ` }, item.value))) : (react_1.default.createElement("p", { className: `${item.contentClass || 'text-start'} text-sm mr-[5px] w-full truncate`, title: item.value?.toString() || '' }, item.value))));
|
|
209
209
|
}
|
|
@@ -21,10 +21,10 @@ export interface DropDownPropsType {
|
|
|
21
21
|
content?: string;
|
|
22
22
|
value?: string;
|
|
23
23
|
} | null;
|
|
24
|
-
type:
|
|
24
|
+
type: "courier" | "item" | "person" | "simple" | "geography";
|
|
25
25
|
placeholder?: string;
|
|
26
26
|
modalOpenHandler?: (value: boolean) => void;
|
|
27
27
|
disable?: boolean;
|
|
28
|
-
inlineStyle?: object;
|
|
28
|
+
inlineStyle?: object | React.CSSProperties;
|
|
29
29
|
preSelectedItemById?: number;
|
|
30
30
|
}
|