hi-tm 0.9.9 → 0.10.0

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,3 +1,3 @@
1
1
  import React from "react";
2
2
  import type { SelectOption, CreatableSelectProps } from "../../types/DropDown/CreatableDropDown";
3
- export default function CreatableSelect<T = SelectOption>({ options, value, onChange, onClick, onValueChange, onCreateOption, placeholder, isLoading, isDisabled, isCreatable, isMultiSelect, noOptionsMessage, noResultsFound, loadingMessage, createOptionMessage, className, tailwindStyle, iconSrc, fetchOptions, label, onAddClick, getOptionLabel, getOptionValue, onFocusShowAllData, }: CreatableSelectProps<T>): React.JSX.Element;
3
+ export default function CreatableSelect<T = SelectOption>({ options, value, onChange, onClick, onValueChange, onCreateOption, placeholder, isLoading, isDisabled, isCreatable, isMultiSelect, noOptionsMessage, noResultsFound, loadingMessage, createOptionMessage, className, tailwindStyle, iconSrc, fetchOptions, label, onAddClick, getOptionLabel, getOptionValue, }: CreatableSelectProps<T>): React.JSX.Element;
@@ -89,7 +89,7 @@ const renderNoResults = (noResults, className, searchIcon) => {
89
89
  return noResults;
90
90
  }
91
91
  };
92
- function CreatableSelect({ options = [], value, onChange, onClick, onValueChange, onCreateOption, placeholder = "جست‌وجو", isLoading = false, isDisabled = false, isCreatable = true, isMultiSelect = false, noOptionsMessage = "مقدار پیشفرضی وجود ندارد", noResultsFound, loadingMessage = "در حال بارگذاری...", createOptionMessage = "ایجاد ", className = "", tailwindStyle = {}, iconSrc = {}, fetchOptions, label, onAddClick, getOptionLabel, getOptionValue, onFocusShowAllData, }) {
92
+ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange, onCreateOption, placeholder = "جست‌وجو", isLoading = false, isDisabled = false, isCreatable = true, isMultiSelect = false, noOptionsMessage = "مقدار پیشفرضی وجود ندارد", noResultsFound, loadingMessage = "در حال بارگذاری...", createOptionMessage = "ایجاد ", className = "", tailwindStyle = {}, iconSrc = {}, fetchOptions, label, onAddClick, getOptionLabel, getOptionValue, }) {
93
93
  // Default icons
94
94
  const defaultIcons = {
95
95
  dropdownOpen: "▼",
@@ -380,6 +380,15 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
380
380
  }
381
381
  }
382
382
  }, [isDisabled, isOpen]);
383
+ const handleFocusClick = (0, react_1.useCallback)((e) => {
384
+ e.preventDefault();
385
+ if (!isDisabled) {
386
+ setIsOpen((prev) => !prev);
387
+ if (!isOpen && inputRef.current) {
388
+ inputRef.current.focus({ preventScroll: true });
389
+ }
390
+ }
391
+ }, [isDisabled, isOpen]);
383
392
  return (react_1.default.createElement("div", { ref: containerRef, className: `relative w-full ${className} ${styles.container}`, onKeyDown: handleKeyDown },
384
393
  label && (react_1.default.createElement("label", { className: "block text-sm font-medium text-gray-700 mb-1" }, label)),
385
394
  react_1.default.createElement("div", { className: `${styles.trigger} ${isDisabled ? "bg-gray-100 cursor-not-allowed" : ""} ${isOpen ? "border-blue-500 ring-2 ring-blue-100" : "border-gray-300"}`, onClick: handleTriggerClick },
@@ -389,9 +398,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
389
398
  selectedValues.map((val) => (react_1.default.createElement("div", { key: deriveValue(val), className: "flex-shrink-0 flex items-center bg-gray-200 rounded-md px-2 py-1" },
390
399
  react_1.default.createElement("span", { className: "truncate" }, deriveLabel(val)),
391
400
  react_1.default.createElement("button", { type: "button", onClick: (e) => clearValue(e, val), className: styles.clearButton }, renderIcon(icons.clear, styles.icon))))),
392
- react_1.default.createElement("input", { ref: inputRef, type: "text", className: `${styles.input} ${isDisabled ? "bg-gray-100" : ""} min-w-[80px] flex-shrink-0`, placeholder: selectedValues.length > 0 ? "" : placeholder, value: inputValue, onChange: handleInputChange, disabled: isDisabled, onClick: (e) => e.stopPropagation(), onFocus: () => {
393
- console.log("focus");
394
- } }))),
401
+ react_1.default.createElement("input", { ref: inputRef, type: "text", className: `${styles.input} ${isDisabled ? "bg-gray-100" : ""} min-w-[80px] flex-shrink-0`, placeholder: selectedValues.length > 0 ? "" : placeholder, value: inputValue, onChange: handleInputChange, disabled: isDisabled, onClick: (e) => e.stopPropagation(), onFocus: handleFocusClick }))),
395
402
  react_1.default.createElement("div", { className: "flex-shrink-0 flex items-center gap-1 ml-2" },
396
403
  iconSrc.hasAdd && (react_1.default.createElement("button", { type: "button", onClick: handleAddIconClick, className: styles.clearButton }, renderIcon(iconSrc.hasAdd, styles.icon))),
397
404
  styles.separator && react_1.default.createElement("div", { className: styles.separator }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.9.9",
3
+ "version": "0.10.0",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {