@tecsinapse/cortex-react 1.3.0-beta.16 → 1.3.0-beta.17

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.
@@ -18,7 +18,7 @@ const SelectMultiGroupedOptions = ({
18
18
  {
19
19
  option,
20
20
  key: keyExtractor(option),
21
- onSelectOption: (option2) => utils.handleSelectMulti(option2, currentValue, onSelect)
21
+ onSelectOption: (option2) => utils.handleSelectMulti(option2, currentValue, onSelect, keyExtractor)
22
22
  }
23
23
  )))));
24
24
  };
@@ -15,7 +15,7 @@ const SelectMultiOptions = ({
15
15
  {
16
16
  option,
17
17
  key: keyExtractor(option),
18
- onSelectOption: (option2) => utils.handleSelectMulti(option2, currentValue, onSelect)
18
+ onSelectOption: (option2) => utils.handleSelectMulti(option2, currentValue, onSelect, keyExtractor)
19
19
  }
20
20
  )));
21
21
  };
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const handleSelectMulti = (option, value, onSelect) => {
3
+ const handleSelectMulti = (option, value, onSelect, keyExtractor) => {
4
4
  const current = Array.from(value ?? []);
5
- const indexOf = current.indexOf(option);
5
+ const indexOf = current.findIndex(
6
+ (it) => keyExtractor(it) === keyExtractor(option)
7
+ );
6
8
  if (indexOf === -1) {
7
9
  current.push(option);
8
10
  } else {
@@ -16,7 +16,7 @@ const SelectMultiGroupedOptions = ({
16
16
  {
17
17
  option,
18
18
  key: keyExtractor(option),
19
- onSelectOption: (option2) => handleSelectMulti(option2, currentValue, onSelect)
19
+ onSelectOption: (option2) => handleSelectMulti(option2, currentValue, onSelect, keyExtractor)
20
20
  }
21
21
  )))));
22
22
  };
@@ -13,7 +13,7 @@ const SelectMultiOptions = ({
13
13
  {
14
14
  option,
15
15
  key: keyExtractor(option),
16
- onSelectOption: (option2) => handleSelectMulti(option2, currentValue, onSelect)
16
+ onSelectOption: (option2) => handleSelectMulti(option2, currentValue, onSelect, keyExtractor)
17
17
  }
18
18
  )));
19
19
  };
@@ -1,6 +1,8 @@
1
- const handleSelectMulti = (option, value, onSelect) => {
1
+ const handleSelectMulti = (option, value, onSelect, keyExtractor) => {
2
2
  const current = Array.from(value ?? []);
3
- const indexOf = current.indexOf(option);
3
+ const indexOf = current.findIndex(
4
+ (it) => keyExtractor(it) === keyExtractor(option)
5
+ );
4
6
  if (indexOf === -1) {
5
7
  current.push(option);
6
8
  } else {
@@ -1 +1 @@
1
- export declare const handleSelectMulti: <T>(option: T, value: T[], onSelect: (value: T[]) => void) => void;
1
+ export declare const handleSelectMulti: <T>(option: T, value: T[], onSelect: (value: T[]) => void, keyExtractor: (value: T) => string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.3.0-beta.16",
3
+ "version": "1.3.0-beta.17",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@floating-ui/react": "^0.26.18",
22
22
  "@internationalized/date": "*",
23
- "@tecsinapse/cortex-core": "0.3.0-beta.8",
23
+ "@tecsinapse/cortex-core": "0.3.0-beta.9",
24
24
  "clsx": "*",
25
25
  "react-aria": "^3.33.1",
26
26
  "react-icons": "^5.2.1",
@@ -43,5 +43,5 @@
43
43
  "react-dom": ">=18.0.0",
44
44
  "tailwind": ">=3.3.0"
45
45
  },
46
- "gitHead": "61cbf81c03570640266b11e0330e7da91344006b"
46
+ "gitHead": "efc6657898e476d4e0f05e76569ff231b4155db8"
47
47
  }