hi-tm 0.5.7 → 0.5.8

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.
@@ -180,6 +180,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
180
180
  setFilteredOptions(filtered);
181
181
  setHasSearched(true);
182
182
  }
183
+ // Don't clear selectedValues here - preserve them during search
183
184
  }, [onChange, fetchOptions, options, deriveLabel]);
184
185
  const handleKeyDown = (0, react_1.useCallback)((e) => {
185
186
  if (isDisabled)
@@ -234,6 +235,25 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
234
235
  onValueChange(isMultiSelect ? next ?? [] : next ? next[0] : null);
235
236
  }
236
237
  }, [onClick, onValueChange, isMultiSelect]);
238
+ const selectOption = (0, react_1.useCallback)((option) => {
239
+ if (isMultiSelect) {
240
+ const next = [...selectedValues];
241
+ if (!next.some((val) => deriveValue(val) === deriveValue(option))) {
242
+ next.push(option);
243
+ }
244
+ setSelectedValues(next);
245
+ emitSelection(next);
246
+ }
247
+ else {
248
+ const next = [option];
249
+ setSelectedValues(next);
250
+ emitSelection(next);
251
+ }
252
+ // Only clear input and close dropdown when actually selecting an option
253
+ setInputValue('');
254
+ setIsOpen(false);
255
+ setHasSearched(false);
256
+ }, [isMultiSelect, selectedValues, deriveValue, emitSelection]);
237
257
  const handleCreateOption = (0, react_1.useCallback)(async () => {
238
258
  if (!inputValue.trim() || !isCreatable)
239
259
  return;
@@ -248,7 +268,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
248
268
  };
249
269
  const optionToAdd = created ?? fallback;
250
270
  selectOption(optionToAdd);
251
- setInputValue('');
271
+ // Don't clear input here as selectOption will handle it
252
272
  setHasSearched(false);
253
273
  }
254
274
  catch {
@@ -256,7 +276,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
256
276
  finally {
257
277
  setInternalLoading(false);
258
278
  }
259
- }, [inputValue, isCreatable, onCreateOption]);
279
+ }, [inputValue, isCreatable, onCreateOption, selectOption]);
260
280
  const toggleDropdown = (0, react_1.useCallback)(() => {
261
281
  if (!isDisabled) {
262
282
  setIsOpen((prev) => !prev);
@@ -271,24 +291,6 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
271
291
  setSelectedValues(next);
272
292
  emitSelection(next);
273
293
  }, [selectedValues, deriveValue, emitSelection]);
274
- const selectOption = (0, react_1.useCallback)((option) => {
275
- if (isMultiSelect) {
276
- const next = [...selectedValues];
277
- if (!next.some((val) => deriveValue(val) === deriveValue(option))) {
278
- next.push(option);
279
- }
280
- setSelectedValues(next);
281
- emitSelection(next);
282
- }
283
- else {
284
- const next = [option];
285
- setSelectedValues(next);
286
- emitSelection(next);
287
- }
288
- setInputValue('');
289
- setIsOpen(false);
290
- setHasSearched(false);
291
- }, [isMultiSelect, selectedValues, deriveValue, emitSelection]);
292
294
  const showLoading = isLoading || internalLoading;
293
295
  const handleAddIconClick = (0, react_1.useCallback)((e) => {
294
296
  e.stopPropagation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {