hi-tm 0.5.8 → 0.5.9

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.
@@ -123,15 +123,6 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
123
123
  setFilteredOptions(options ?? []);
124
124
  }
125
125
  }, [options, hasSearched]);
126
- // Sync selectedValues with the value prop
127
- (0, react_1.useEffect)(() => {
128
- if (isMultiSelect) {
129
- setSelectedValues(Array.isArray(value) ? value : value ? [value] : []);
130
- }
131
- else {
132
- setSelectedValues(value ? [value] : []);
133
- }
134
- }, [value, isMultiSelect]);
135
126
  // Reset filtered list when input cleared
136
127
  (0, react_1.useEffect)(() => {
137
128
  if (inputValue === '') {
@@ -180,7 +171,6 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
180
171
  setFilteredOptions(filtered);
181
172
  setHasSearched(true);
182
173
  }
183
- // Don't clear selectedValues here - preserve them during search
184
174
  }, [onChange, fetchOptions, options, deriveLabel]);
185
175
  const handleKeyDown = (0, react_1.useCallback)((e) => {
186
176
  if (isDisabled)
@@ -235,25 +225,6 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
235
225
  onValueChange(isMultiSelect ? next ?? [] : next ? next[0] : null);
236
226
  }
237
227
  }, [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]);
257
228
  const handleCreateOption = (0, react_1.useCallback)(async () => {
258
229
  if (!inputValue.trim() || !isCreatable)
259
230
  return;
@@ -268,7 +239,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
268
239
  };
269
240
  const optionToAdd = created ?? fallback;
270
241
  selectOption(optionToAdd);
271
- // Don't clear input here as selectOption will handle it
242
+ setInputValue('');
272
243
  setHasSearched(false);
273
244
  }
274
245
  catch {
@@ -276,7 +247,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
276
247
  finally {
277
248
  setInternalLoading(false);
278
249
  }
279
- }, [inputValue, isCreatable, onCreateOption, selectOption]);
250
+ }, [inputValue, isCreatable, onCreateOption]);
280
251
  const toggleDropdown = (0, react_1.useCallback)(() => {
281
252
  if (!isDisabled) {
282
253
  setIsOpen((prev) => !prev);
@@ -291,6 +262,24 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
291
262
  setSelectedValues(next);
292
263
  emitSelection(next);
293
264
  }, [selectedValues, deriveValue, emitSelection]);
265
+ const selectOption = (0, react_1.useCallback)((option) => {
266
+ if (isMultiSelect) {
267
+ const next = [...selectedValues];
268
+ if (!next.some((val) => deriveValue(val) === deriveValue(option))) {
269
+ next.push(option);
270
+ }
271
+ setSelectedValues(next);
272
+ emitSelection(next);
273
+ }
274
+ else {
275
+ const next = [option];
276
+ setSelectedValues(next);
277
+ emitSelection(next);
278
+ }
279
+ setInputValue('');
280
+ setIsOpen(false);
281
+ setHasSearched(false);
282
+ }, [isMultiSelect, selectedValues, deriveValue, emitSelection]);
294
283
  const showLoading = isLoading || internalLoading;
295
284
  const handleAddIconClick = (0, react_1.useCallback)((e) => {
296
285
  e.stopPropagation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {