@tecsinapse/cortex-react 1.5.1 → 1.5.2

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.
@@ -17,18 +17,21 @@ const SelectMultiCheckAllOptions = ({
17
17
  );
18
18
  const checkAll = React.useCallback(() => {
19
19
  {
20
- let updateSelected = [...currentValue];
20
+ const updateSelected = Array.from(currentValue);
21
21
  if (!isChecked) {
22
- updateSelected = [
23
- .../* @__PURE__ */ new Set([...updateSelected, ...options ?? []])
24
- ];
25
- } else {
26
- const optionKeys = new Set(
27
- options?.map((option2) => keyExtractor(option2))
28
- );
29
- updateSelected = updateSelected.filter(
30
- (item) => !optionKeys.has(keyExtractor(item))
22
+ const notSelected = options?.filter(
23
+ (option2) => !updateSelected.find(
24
+ (it) => keyExtractor(it) === keyExtractor(option2)
25
+ )
31
26
  );
27
+ updateSelected.push(...notSelected ?? []);
28
+ } else {
29
+ const elementsToDelete = updateSelected.map(
30
+ (it) => options?.find((option2) => keyExtractor(option2) === keyExtractor(it))
31
+ ).filter((it) => it);
32
+ elementsToDelete.map((it) => {
33
+ updateSelected.splice(updateSelected.indexOf(it), 1);
34
+ });
32
35
  }
33
36
  onSelect(updateSelected);
34
37
  }
@@ -15,18 +15,21 @@ const SelectMultiCheckAllOptions = ({
15
15
  );
16
16
  const checkAll = useCallback(() => {
17
17
  {
18
- let updateSelected = [...currentValue];
18
+ const updateSelected = Array.from(currentValue);
19
19
  if (!isChecked) {
20
- updateSelected = [
21
- .../* @__PURE__ */ new Set([...updateSelected, ...options ?? []])
22
- ];
23
- } else {
24
- const optionKeys = new Set(
25
- options?.map((option2) => keyExtractor(option2))
26
- );
27
- updateSelected = updateSelected.filter(
28
- (item) => !optionKeys.has(keyExtractor(item))
20
+ const notSelected = options?.filter(
21
+ (option2) => !updateSelected.find(
22
+ (it) => keyExtractor(it) === keyExtractor(option2)
23
+ )
29
24
  );
25
+ updateSelected.push(...notSelected ?? []);
26
+ } else {
27
+ const elementsToDelete = updateSelected.map(
28
+ (it) => options?.find((option2) => keyExtractor(option2) === keyExtractor(it))
29
+ ).filter((it) => it);
30
+ elementsToDelete.map((it) => {
31
+ updateSelected.splice(updateSelected.indexOf(it), 1);
32
+ });
30
33
  }
31
34
  onSelect(updateSelected);
32
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -45,5 +45,5 @@
45
45
  "react-dom": ">=18.0.0",
46
46
  "tailwind": ">=3.3.0"
47
47
  },
48
- "gitHead": "cf0f1a6cda80b413d079a13c2545a0b9244d0805"
48
+ "gitHead": "5b8a619a4dad4ec8a423e1e836d211262c1fc2bd"
49
49
  }