@tanstack/cta-ui-base 0.25.1 → 0.26.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.
- package/dist/store/add-ons.js +22 -5
- package/package.json +2 -2
- package/src/store/add-ons.ts +25 -5
package/dist/store/add-ons.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export function getAddOnStatus(availableAddOns, chosenAddOns, originalAddOns) {
|
|
2
2
|
const addOnMap = new Map();
|
|
3
|
+
const getAddOnType = (addOn) => availableAddOns.find((a) => a.id === addOn).type;
|
|
4
|
+
const isMultiSelect = (addOn) => getAddOnType(addOn) === 'host';
|
|
5
|
+
const areAddonsOfThisTypeCurrentlyChosen = (addOn) => chosenAddOns.some((a) => getAddOnType(a) === getAddOnType(addOn));
|
|
3
6
|
for (const addOn of availableAddOns) {
|
|
4
7
|
addOnMap.set(addOn.id, {
|
|
5
8
|
selected: false,
|
|
@@ -22,7 +25,7 @@ export function getAddOnStatus(availableAddOns, chosenAddOns, originalAddOns) {
|
|
|
22
25
|
const dependsOnAddOn = addOnMap.get(dependsOnId);
|
|
23
26
|
if (dependsOnAddOn) {
|
|
24
27
|
dependsOnAddOn.selected = true;
|
|
25
|
-
dependsOnAddOn.enabled = false;
|
|
28
|
+
dependsOnAddOn.enabled = isMultiSelect(dependsOnId) ? true : false;
|
|
26
29
|
dependsOnAddOn.dependedUpon = true;
|
|
27
30
|
selectAndDisableDependsOn(dependsOnId);
|
|
28
31
|
}
|
|
@@ -41,11 +44,25 @@ export function getAddOnStatus(availableAddOns, chosenAddOns, originalAddOns) {
|
|
|
41
44
|
for (const addOn of originalAddOns) {
|
|
42
45
|
const addOnInfo = addOnMap.get(addOn);
|
|
43
46
|
if (addOnInfo) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
if (isMultiSelect(addOn)) {
|
|
48
|
+
if (areAddonsOfThisTypeCurrentlyChosen(addOn)) {
|
|
49
|
+
addOnInfo.selected = false;
|
|
50
|
+
addOnInfo.enabled = true;
|
|
51
|
+
addOnInfo.dependedUpon = false;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
addOnInfo.selected = true;
|
|
55
|
+
addOnInfo.enabled = true;
|
|
56
|
+
addOnInfo.dependedUpon = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
addOnInfo.selected = true;
|
|
61
|
+
addOnInfo.enabled = false;
|
|
62
|
+
addOnInfo.dependedUpon = true;
|
|
63
|
+
cycleGuardedSelectAndDisableDependsOn(addOn);
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
|
-
cycleGuardedSelectAndDisableDependsOn(addOn);
|
|
49
66
|
}
|
|
50
67
|
for (const addOnId of chosenAddOns) {
|
|
51
68
|
cycleGuardedSelectAndDisableDependsOn(addOnId);
|
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"sonner": "^2.0.3",
|
|
37
37
|
"tailwind-merge": "^3.0.2",
|
|
38
38
|
"zustand": "^5.0.3",
|
|
39
|
-
"@tanstack/cta-engine": "0.
|
|
39
|
+
"@tanstack/cta-engine": "0.26.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/react": "^19.0.8",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"vite-tsconfig-paths": "^5.1.4",
|
|
46
46
|
"vitest": "^3.1.4"
|
|
47
47
|
},
|
|
48
|
-
"version": "0.
|
|
48
|
+
"version": "0.26.0",
|
|
49
49
|
"scripts": {}
|
|
50
50
|
}
|
package/src/store/add-ons.ts
CHANGED
|
@@ -15,6 +15,14 @@ export function getAddOnStatus(
|
|
|
15
15
|
}
|
|
16
16
|
>()
|
|
17
17
|
|
|
18
|
+
const getAddOnType = (addOn: string) =>
|
|
19
|
+
availableAddOns.find((a) => a.id === addOn)!.type
|
|
20
|
+
|
|
21
|
+
const isMultiSelect = (addOn: string) => getAddOnType(addOn) === 'host'
|
|
22
|
+
|
|
23
|
+
const areAddonsOfThisTypeCurrentlyChosen = (addOn: string) =>
|
|
24
|
+
chosenAddOns.some((a) => getAddOnType(a) === getAddOnType(addOn))
|
|
25
|
+
|
|
18
26
|
for (const addOn of availableAddOns) {
|
|
19
27
|
addOnMap.set(addOn.id, {
|
|
20
28
|
selected: false,
|
|
@@ -40,7 +48,7 @@ export function getAddOnStatus(
|
|
|
40
48
|
const dependsOnAddOn = addOnMap.get(dependsOnId)
|
|
41
49
|
if (dependsOnAddOn) {
|
|
42
50
|
dependsOnAddOn.selected = true
|
|
43
|
-
dependsOnAddOn.enabled = false
|
|
51
|
+
dependsOnAddOn.enabled = isMultiSelect(dependsOnId) ? true : false
|
|
44
52
|
dependsOnAddOn.dependedUpon = true
|
|
45
53
|
selectAndDisableDependsOn(dependsOnId)
|
|
46
54
|
}
|
|
@@ -60,11 +68,23 @@ export function getAddOnStatus(
|
|
|
60
68
|
for (const addOn of originalAddOns) {
|
|
61
69
|
const addOnInfo = addOnMap.get(addOn)
|
|
62
70
|
if (addOnInfo) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
if (isMultiSelect(addOn)) {
|
|
72
|
+
if (areAddonsOfThisTypeCurrentlyChosen(addOn)) {
|
|
73
|
+
addOnInfo.selected = false
|
|
74
|
+
addOnInfo.enabled = true
|
|
75
|
+
addOnInfo.dependedUpon = false
|
|
76
|
+
} else {
|
|
77
|
+
addOnInfo.selected = true
|
|
78
|
+
addOnInfo.enabled = true
|
|
79
|
+
addOnInfo.dependedUpon = true
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
addOnInfo.selected = true
|
|
83
|
+
addOnInfo.enabled = false
|
|
84
|
+
addOnInfo.dependedUpon = true
|
|
85
|
+
cycleGuardedSelectAndDisableDependsOn(addOn)
|
|
86
|
+
}
|
|
66
87
|
}
|
|
67
|
-
cycleGuardedSelectAndDisableDependsOn(addOn)
|
|
68
88
|
}
|
|
69
89
|
|
|
70
90
|
for (const addOnId of chosenAddOns) {
|