@@ -21,6 +21,7 @@ export interface FilterCategoryConfig {
21
21
property : keyof ScheduleSession
22
22
label : string
23
23
options : string [ ]
24
+ enabledOptions ?: Set < string >
24
25
}
25
26
26
27
export const FilterCategoryConfig = {
@@ -33,7 +34,11 @@ export const FilterCategoryConfig = {
33
34
property : field as keyof ScheduleSession ,
34
35
label,
35
36
options : Array . from (
36
- new Set ( scheduleData . map ( session => session [ field ] ) ) ,
37
+ new Set (
38
+ scheduleData . map (
39
+ session => session [ field as keyof ScheduleSession ] ,
40
+ ) ,
41
+ ) ,
37
42
) . filter ( ( x ) : x is string => ! ! x && typeof x === "string" ) ,
38
43
} ) ,
39
44
)
@@ -51,12 +56,14 @@ export const FilterStates = {
51
56
type FiltersProps = {
52
57
categories : FilterCategoryConfig [ ]
53
58
filterState : Record < string , string [ ] >
59
+ enabledOptions : Record < string , Set < string > >
54
60
onFilterChange : ( category : string , newSelectedOptions : string [ ] ) => void
55
61
}
56
62
57
63
export function Filters ( {
58
64
categories,
59
65
filterState,
66
+ enabledOptions,
60
67
onFilterChange,
61
68
} : FiltersProps ) {
62
69
return (
@@ -66,6 +73,7 @@ export function Filters({
66
73
key = { category . property }
67
74
label = { category . label }
68
75
options = { category . options }
76
+ enabledOptions = { enabledOptions [ category . property ] }
69
77
value = { filterState [ category . property ] || [ ] }
70
78
onChange = { newSelectedOptions => {
71
79
onFilterChange ( category . property , newSelectedOptions )
@@ -109,6 +117,7 @@ export function ResetFiltersButton({
109
117
interface FiltersComboboxProps {
110
118
label : string
111
119
options : string [ ]
120
+ enabledOptions : Set < string >
112
121
value : string [ ]
113
122
onChange : ( newSelectedOptions : string [ ] ) => void
114
123
placeholder : string
@@ -117,6 +126,7 @@ interface FiltersComboboxProps {
117
126
function FiltersCombobox ( {
118
127
label,
119
128
options,
129
+ enabledOptions,
120
130
value,
121
131
onChange,
122
132
placeholder,
@@ -182,7 +192,11 @@ function FiltersCombobox({
182
192
) }
183
193
>
184
194
{ filteredOptions . map ( option => (
185
- < ComboboxOption key = { option } value = { option } >
195
+ < ComboboxOption
196
+ key = { option }
197
+ value = { option }
198
+ disabled = { ! enabledOptions . has ( option ) }
199
+ >
186
200
{ ( { active, selected } ) => (
187
201
< FilterComboboxOption
188
202
active = { active }
@@ -248,6 +262,7 @@ function FilterComboboxOption({
248
262
className = { clsx (
249
263
"typography-body-sm relative flex cursor-default select-none items-center p-1 font-sans" ,
250
264
active && "bg-neu-100 dark:bg-neu-50" ,
265
+ "[[data-disabled]_&]:line-through [[data-disabled]_&]:opacity-40" ,
251
266
) }
252
267
>
253
268
< CheckboxIcon
0 commit comments