hi-tm 0.8.9 → 0.9.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.
@@ -50,7 +50,8 @@ const defaultStyles = {
50
50
  noResults: 'py-4 px-3 text-gray-500 flex flex-col items-center justify-center gap-2',
51
51
  clearButton: 'p-1 rounded-full hover:bg-gray-100',
52
52
  icon: 'w-4 h-4 text-gray-400',
53
- separator: 'h-4 border-l mx-2', // Style for the vertical line separator
53
+ separator: 'h-4 border-l mx-2',
54
+ selectedOptionIcon: 'w-4 h-4 mr-2 text-blue-500', // Added style for selected option icon
54
55
  };
55
56
  // Helper function to render different icon types
56
57
  const renderIcon = (icon, className = '') => {
@@ -349,7 +350,6 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
349
350
  setHasSearched(false);
350
351
  }
351
352
  }, [isMultiSelect, selectedValues, deriveValue, emitSelection]);
352
- const showLoading = isLoading || internalLoading;
353
353
  const handleAddIconClick = (0, react_1.useCallback)((e) => {
354
354
  e.preventDefault();
355
355
  e.stopPropagation();
@@ -366,6 +366,11 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
366
366
  }
367
367
  }
368
368
  }, [isDisabled, isOpen]);
369
+ const showLoading = isLoading || internalLoading;
370
+ // Helper function to check if an option is selected
371
+ const isOptionSelected = (0, react_1.useCallback)((option) => {
372
+ return selectedValues.some((val) => deriveValue(val) === deriveValue(option));
373
+ }, [selectedValues, deriveValue]);
369
374
  return (react_1.default.createElement("div", { ref: containerRef, className: `relative w-full ${className} ${styles.container}`, onKeyDown: handleKeyDown },
370
375
  label && react_1.default.createElement("label", { className: "block text-sm font-medium text-gray-700 mb-1" }, label),
371
376
  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 },
@@ -386,11 +391,9 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
386
391
  renderIcon(iconSrc.loading, `animate-spin mr-2 ${styles.icon}`),
387
392
  loadingMessage)) : (react_1.default.createElement(react_1.default.Fragment, null,
388
393
  filteredOptions.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null, filteredOptions.map((option, index) => (react_1.default.createElement("div", { key: deriveValue(option), className: `${styles.option} ${index === highlightedIndex ? styles.highlightedOption : 'hover:bg-gray-50'}`, onClick: () => selectOption(option), onMouseEnter: () => setHighlightedIndex(index) },
389
- selectedValues.some((val) => deriveValue(val) === deriveValue(option)) &&
390
- renderIcon(iconSrc.checkmark, 'w-4 h-4 mr-2 text-blue-500'),
391
- react_1.default.createElement("span", { className: selectedValues.some((val) => deriveValue(val) === deriveValue(option))
392
- ? styles.selectedOption
393
- : '' }, deriveLabel(option) || deriveValue(option))))))),
394
+ isOptionSelected(option) &&
395
+ renderIcon(icons.checkmark, styles.selectedOptionIcon || styles.icon),
396
+ react_1.default.createElement("span", { className: isOptionSelected(option) ? styles.selectedOption : '' }, deriveLabel(option) || deriveValue(option))))))),
394
397
  filteredOptions.length === 0 && !inputValue && (react_1.default.createElement("div", { className: styles.noOptions }, noOptionsMessage)),
395
398
  filteredOptions.length === 0 &&
396
399
  inputValue &&
@@ -29,6 +29,7 @@ export interface TailwindStyleProps extends React.CSSProperties {
29
29
  icon?: string;
30
30
  separator?: string;
31
31
  spinAnimation?: string;
32
+ selectedOptionIcon?: string;
32
33
  }
33
34
  export type BaseOption = {
34
35
  label?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.8.9",
3
+ "version": "0.9.0",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {