hi-tm 0.9.8 → 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.
|
@@ -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,7 +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() }))),
|
|
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 }))),
|
|
393
402
|
react_1.default.createElement("div", { className: "flex-shrink-0 flex items-center gap-1 ml-2" },
|
|
394
403
|
iconSrc.hasAdd && (react_1.default.createElement("button", { type: "button", onClick: handleAddIconClick, className: styles.clearButton }, renderIcon(iconSrc.hasAdd, styles.icon))),
|
|
395
404
|
styles.separator && react_1.default.createElement("div", { className: styles.separator }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
export type IconType = ReactNode | string | {
|
|
3
3
|
src: string;
|
|
4
4
|
alt?: string;
|
|
@@ -71,4 +71,5 @@ export type CreatableSelectProps<T = SelectOption> = {
|
|
|
71
71
|
isMultiSelect?: boolean;
|
|
72
72
|
getOptionLabel?: OptionLabelGetter<T>;
|
|
73
73
|
getOptionValue?: OptionValueGetter<T>;
|
|
74
|
+
onFocusShowAllData?: boolean;
|
|
74
75
|
};
|