hi-tm 0.14.1 → 0.14.3

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.
@@ -1,25 +1,7 @@
1
1
  import { InputCurrencyPropsType } from "../../types/Inputs/InputCurrencyType";
2
2
  import React from "react";
3
- /**
4
- * InputCurrency Component
5
- * A controlled input field for currency values, supporting Persian and English numerals,
6
- * and providing validation, error handling, and additional handlers for customization.
7
- *
8
- * @param placeholder - The placeholder text for the input field.
9
- * @param value - The initial value of the input field => (Just Number whit number type OR Null).
10
- * @param required - Indicates if the input field is required. Displays a red asterisk (*) if true. => (boolean)
11
- * @param currencyUnit - The currency unit to be displayed. => (string)
12
- * @param textError - (optional) The error message to display when validation fails. => {string or null}
13
- * @param label - The label for the input field. => (string)
14
- * @param autoComplete - Enables or disables autocomplete => (boolean).
15
- * @param autoFocus - Automatically focuses the input field when true. => (boolean)
16
- * @param onChangeValueHandler - A callback function triggered when the input value changes.
17
- * @param onBlurHandler - (optional) A callback function triggered when the input field loses focus. => If not received, the input will not be blurred.
18
- * @param onFocusHandler - (optional) A callback function triggered when the input field gains focus. => If not received, the input will not be focused.
19
- * @param onKeyUpHandler - (optional) A callback function triggered on key release events.
20
- * @param onKeyDownHandler - (optional) A callback function triggered on key press events.
21
- *
22
- * @returns React.JSX.Element
23
- */
24
- declare const InputCurrency: ({ placeholder, value, required, currencyUnit, textError, label, autoComplete, autoFocus, inlineCss, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled, }: InputCurrencyPropsType) => React.JSX.Element;
3
+ interface InputCurrencyWithRefProps extends InputCurrencyPropsType {
4
+ inputRef?: React.Ref<HTMLInputElement>;
5
+ }
6
+ declare const InputCurrency: React.ForwardRefExoticComponent<InputCurrencyWithRefProps & React.RefAttributes<HTMLInputElement>>;
25
7
  export default InputCurrency;
@@ -35,40 +35,20 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  const react_1 = __importStar(require("react"));
38
- /**
39
- * InputCurrency Component
40
- * A controlled input field for currency values, supporting Persian and English numerals,
41
- * and providing validation, error handling, and additional handlers for customization.
42
- *
43
- * @param placeholder - The placeholder text for the input field.
44
- * @param value - The initial value of the input field => (Just Number whit number type OR Null).
45
- * @param required - Indicates if the input field is required. Displays a red asterisk (*) if true. => (boolean)
46
- * @param currencyUnit - The currency unit to be displayed. => (string)
47
- * @param textError - (optional) The error message to display when validation fails. => {string or null}
48
- * @param label - The label for the input field. => (string)
49
- * @param autoComplete - Enables or disables autocomplete => (boolean).
50
- * @param autoFocus - Automatically focuses the input field when true. => (boolean)
51
- * @param onChangeValueHandler - A callback function triggered when the input value changes.
52
- * @param onBlurHandler - (optional) A callback function triggered when the input field loses focus. => If not received, the input will not be blurred.
53
- * @param onFocusHandler - (optional) A callback function triggered when the input field gains focus. => If not received, the input will not be focused.
54
- * @param onKeyUpHandler - (optional) A callback function triggered on key release events.
55
- * @param onKeyDownHandler - (optional) A callback function triggered on key press events.
56
- *
57
- * @returns React.JSX.Element
58
- */
59
- const InputCurrency = ({ placeholder, value, required, currencyUnit, textError, label, autoComplete, autoFocus, inlineCss, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled = false, }) => {
38
+ const InputCurrency = (0, react_1.forwardRef)(({ placeholder, value, required, currencyUnit, textError, label, autoComplete, autoFocus, inlineCss, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled = false, }, ref) => {
60
39
  const [inputValue, setInputValue] = (0, react_1.useState)(value?.toString() || "");
61
- const inputRef = (0, react_1.useRef)(null);
40
+ const internalRef = (0, react_1.useRef)(null);
41
+ // Combine the external ref with the internal ref
42
+ react_1.default.useImperativeHandle(ref, () => internalRef.current);
62
43
  (0, react_1.useEffect)(() => {
63
44
  if (value !== null) {
64
45
  setInputValue(value?.toString());
65
46
  }
66
47
  }, [value]);
67
- // Cursor display direction
68
48
  (0, react_1.useEffect)(() => {
69
- if (inputRef.current && value !== null) {
70
- inputRef.current.selectionStart = inputRef.current.value.length;
71
- inputRef.current.selectionEnd = inputRef.current.value.length;
49
+ if (internalRef.current && value !== null) {
50
+ internalRef.current.selectionStart = internalRef.current.value.length;
51
+ internalRef.current.selectionEnd = internalRef.current.value.length;
72
52
  }
73
53
  }, [value]);
74
54
  const isErrorVisible = () => {
@@ -76,7 +56,6 @@ const InputCurrency = ({ placeholder, value, required, currencyUnit, textError,
76
56
  };
77
57
  const handleChange = (event) => {
78
58
  const newValue = event.target.value;
79
- // Being allowed to enter Persian numbers
80
59
  const validValue = newValue.replace(/[^\d۰-۹]/g, "");
81
60
  setInputValue(validValue);
82
61
  onChangeValueHandler(event);
@@ -100,12 +79,13 @@ const InputCurrency = ({ placeholder, value, required, currencyUnit, textError,
100
79
  react_1.default.createElement("div", { className: "w-full relative", style: inlineCss },
101
80
  react_1.default.createElement("label", { htmlFor: label, className: "flex items-center gap-2 mx-3" },
102
81
  react_1.default.createElement("p", { className: "text-sm text-text-color-primary font-medium cursor-pointer" }, label),
103
- react_1.default.createElement("span", { className: `text-red-primary ${required ? "opacity-100" : "opacity-0"} ` }, "*")),
82
+ required && react_1.default.createElement("span", { className: "text-red-primary" }, "*")),
104
83
  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()
105
84
  ? "border-gray-tertiary focus:border-gray-quaternary"
106
85
  : "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 }),
86
+ react_1.default.createElement("input", { ref: internalRef, 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 }),
108
87
  react_1.default.createElement("p", { className: "text-sm text-text-color-primary border-r border-gray-tertiary px-2" }, currencyUnit)),
109
- !isErrorVisible() && (react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError && textError?.trim())))));
110
- };
88
+ !isErrorVisible() && (react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim())))));
89
+ });
90
+ InputCurrency.displayName = "InputCurrency";
111
91
  exports.default = InputCurrency;
@@ -35,7 +35,7 @@ const ModernTable = ({ rows = [], onEdit, loadingProps = {
35
35
  isLoading: false,
36
36
  loadingText: "درحال دریافت اطلاعات",
37
37
  loadingIcon: react_1.default.createElement(Loader, null),
38
- }, onView, onAction, selectable, onSelectionChange, actions, ShowActionModal = true, modalActions, noItemFoundProps, selectedItems = [], iconsSRC,
38
+ }, onView, onAction, selectable, onSelectionChange, checkBoxDisable, actions, ShowActionModal = true, modalActions, noItemFoundProps, selectedItems = [], iconsSRC,
39
39
  // Child row configuration with defaults
40
40
  childRowConfig = {
41
41
  expandByDefault: false,
@@ -547,7 +547,7 @@ pageIndex = 0, // Default to first page (0-indexed)
547
547
  if (el) {
548
548
  el.indeterminate = isIndeterminate(row.id);
549
549
  }
550
- } })))),
550
+ }, disabled: checkBoxDisable })))),
551
551
  react_1.default.createElement("div", { className: "flex-1 min-w-0" },
552
552
  react_1.default.createElement("div", { className: "flex items-start justify-between" },
553
553
  react_1.default.createElement("div", { className: "overflow-hidden" },
@@ -631,7 +631,7 @@ pageIndex = 0, // Default to first page (0-indexed)
631
631
  if (el) {
632
632
  el.indeterminate = isIndeterminate(row.id);
633
633
  }
634
- } }),
634
+ }, disabled: checkBoxDisable }),
635
635
  isIndeterminate(row.id) ? (react_1.default.createElement("div", { className: "pointer-events-none absolute left-[5px] top-[9px] w-2.5 h-0.5 bg-blue-500" })) : (react_1.default.createElement("svg", { className: "pointer-events-none absolute left-[5px] top-[5px] h-2.5 w-2.5 fill-white opacity-0 transition-opacity peer-checked:opacity-100", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
636
636
  react_1.default.createElement("path", { d: "M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" }))))))),
637
637
  row?.data?.map((item, colIndex) => (react_1.default.createElement("div", { key: `${item.id}-${colIndex}`, className: `h-full select-none text-xs font-medium min-w-0 flex items-center ${item.type === "avatar" ||
@@ -656,7 +656,7 @@ pageIndex = 0, // Default to first page (0-indexed)
656
656
  if (el) {
657
657
  el.indeterminate = isIndeterminate(row.id);
658
658
  }
659
- } }),
659
+ }, disabled: checkBoxDisable }),
660
660
  isIndeterminate(row.id) ? (react_1.default.createElement("div", { className: "pointer-events-none absolute left-[5px] top-[9px] w-2.5 h-0.5 bg-blue-500" })) : (react_1.default.createElement("svg", { className: "pointer-events-none absolute left-[5px] top-[5px] h-2.5 w-2.5 fill-white opacity-0 transition-opacity peer-checked:opacity-100", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
661
661
  react_1.default.createElement("path", { d: "M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" })))))),
662
662
  renderCellContent(item)))),
@@ -72,6 +72,7 @@ export interface ModernTableProps {
72
72
  onAction?: (actionId: number, rowId: number) => void;
73
73
  selectable: boolean;
74
74
  onSelectionChange?: (id: number | number[]) => void;
75
+ checkBoxDisable: boolean;
75
76
  actions?: boolean;
76
77
  ShowActionModal?: boolean;
77
78
  modalActions: ModalAction[] | ((row: TableRowData) => ModalAction[]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {