hi-tm 0.3.3 → 0.3.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.
@@ -14,7 +14,8 @@ import { InputMultiselectProps } from '../../types/Inputs/InputMultiselectType';
14
14
  * @param {Function | undefined} handleKeyDown - Callback function triggered when a key is pressed while the input is focused.
15
15
  * @param {Function | undefined} onBlurHandler - Callback function triggered when the input loses focus.
16
16
  * @param {string} closeIconSRC - The source URL for the close icon image.
17
+ * @param {React.RefObject<HTMLInputElement>} inputRef - Ref for the input element.
17
18
  * @param {string} [width=w-full] - The width of the input container, with a default value of 'w-full'.
18
19
  */
19
- declare const InputMultiselect: ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, style, }: InputMultiselectProps) => React.JSX.Element;
20
+ declare const InputMultiselect: ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, inputRef, style, }: InputMultiselectProps) => React.JSX.Element;
20
21
  export default InputMultiselect;
@@ -53,24 +53,19 @@ const image_1 = __importDefault(require("next/image"));
53
53
  * @param {Function | undefined} handleKeyDown - Callback function triggered when a key is pressed while the input is focused.
54
54
  * @param {Function | undefined} onBlurHandler - Callback function triggered when the input loses focus.
55
55
  * @param {string} closeIconSRC - The source URL for the close icon image.
56
+ * @param {React.RefObject<HTMLInputElement>} inputRef - Ref for the input element.
56
57
  * @param {string} [width=w-full] - The width of the input container, with a default value of 'w-full'.
57
58
  */
58
- const InputMultiselect = ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, style = {
59
+ const InputMultiselect = ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, inputRef, style = {
59
60
  margin: 'mt-[-6px]',
60
61
  width: 'w-full',
61
62
  }, }) => {
62
63
  const [items, setItems] = (0, react_1.useState)([]);
63
64
  const [currentValue, setCurrentValue] = (0, react_1.useState)('');
64
65
  const [showError, setShowError] = (0, react_1.useState)(false);
65
- const inputRef = (0, react_1.useRef)(null);
66
66
  const isErrorVisible = () => {
67
67
  return !(textError && textError.trim() !== '');
68
68
  };
69
- (0, react_1.useEffect)(() => {
70
- if (inputRef.current) {
71
- inputRef.current.value = currentValue;
72
- }
73
- }, [currentValue]);
74
69
  (0, react_1.useEffect)(() => {
75
70
  if (value && value.length > 0) {
76
71
  setItems(value);
@@ -110,7 +105,7 @@ const InputMultiselect = ({ label, required, textError, placeholder, onChangeHan
110
105
  items.map((item, index) => (react_1.default.createElement("span", { key: index, className: "bg-gray-secondary text-text-color-primary px-2 py-1 rounded flex items-center justify-center gap-1" },
111
106
  item,
112
107
  react_1.default.createElement(image_1.default, { src: closeIconSRC, alt: "close", width: 22, height: 22, onClick: () => handleRemoveItem(index), className: "inline-block cursor-pointer" })))),
113
- react_1.default.createElement("input", { ref: inputRef, type: "text", id: label, placeholder: items.length === 0 ? placeholder : '', onChange: handleChange, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, className: "outline-none bg-inherit flex-grow", required: required, onFocus: onFocusHandler, onKeyUp: onKeyUpHandler, onKeyDown: handleKeyDown, onBlur: handleBlur })),
108
+ react_1.default.createElement("input", { ref: inputRef, type: "text", value: currentValue, id: label, placeholder: items.length === 0 ? placeholder : '', onChange: handleChange, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, className: "outline-none bg-inherit flex-grow", required: required, onFocus: onFocusHandler, onKeyUp: onKeyUpHandler, onKeyDown: handleKeyDown, onBlur: handleBlur })),
114
109
  !isErrorVisible() && react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim())));
115
110
  };
116
111
  exports.default = InputMultiselect;
@@ -12,6 +12,7 @@ export interface InputMultiselectProps {
12
12
  handleKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
13
13
  onBlurHandler?: (event: React.FocusEvent) => void;
14
14
  closeIconSRC: string;
15
+ inputRef?: React.RefObject<HTMLInputElement>;
15
16
  style?: {
16
17
  width?: string;
17
18
  margin?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {