code7-leia 0.1.123 → 0.1.124

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.123",
2
+ "version": "0.1.124",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -37,8 +37,9 @@ const MultiSelect: React.FC<MultiSelectProps> = ({ options, presset, setPresset
37
37
  const handleInputKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
38
38
  if (event.key === 'Enter') {
39
39
  event.preventDefault();
40
- if (newOption.trim() !== '' && !options.some(option => option.value === newOption)) {
41
- setPresset(prevPresset => [...prevPresset, newOption]);
40
+ const trimmedOption = newOption.trim();
41
+ if (trimmedOption !== '' && !options.some(option => option.value === trimmedOption)) {
42
+ setPresset(prevPresset => [...prevPresset, trimmedOption]);
42
43
  }
43
44
  setNewOption('');
44
45
  }
@@ -49,9 +50,19 @@ const MultiSelect: React.FC<MultiSelectProps> = ({ options, presset, setPresset
49
50
  <S.MultiSelectWrapper>
50
51
  <S.SelectBox onClick={showCheckboxes}>
51
52
  <select>
52
- <option>Select an option</option>
53
+ {presset.map((option, index) => (
54
+ <option key={index} value={option}>{option}</option>
55
+ ))}
53
56
  </select>
54
- <S.OverSelect />
57
+ <S.OverSelect>
58
+ <input
59
+ type="text"
60
+ placeholder="Add new option"
61
+ value={newOption}
62
+ onChange={handleInputChange}
63
+ onKeyPress={handleInputKeyPress}
64
+ />
65
+ </S.OverSelect>
55
66
  </S.SelectBox>
56
67
  <S.Checkboxes style={{ display: expanded ? 'block' : 'none' }}>
57
68
  {options.map((option, index) => (
@@ -65,21 +76,8 @@ const MultiSelect: React.FC<MultiSelectProps> = ({ options, presset, setPresset
65
76
  {option.label}
66
77
  </S.CheckboxLabel>
67
78
  ))}
68
- <input
69
- type="text"
70
- placeholder="Add new option"
71
- value={newOption}
72
- onChange={handleInputChange}
73
- onKeyPress={handleInputKeyPress}
74
- />
75
79
  </S.Checkboxes>
76
80
  </S.MultiSelectWrapper>
77
- <div>
78
- Selected Options:
79
- {presset.map((selectedOption, index) => (
80
- <span key={index}>{selectedOption}, </span>
81
- ))}
82
- </div>
83
81
  </form>
84
82
  );
85
83
  }