@@ -21,6 +21,7 @@ export interface FilterCategoryConfig {
2121 property : keyof ScheduleSession
2222 label : string
2323 options : string [ ]
24+ enabledOptions ?: Set < string >
2425}
2526
2627export const FilterCategoryConfig = {
@@ -33,7 +34,11 @@ export const FilterCategoryConfig = {
3334 property : field as keyof ScheduleSession ,
3435 label,
3536 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+ ) ,
3742 ) . filter ( ( x ) : x is string => ! ! x && typeof x === "string" ) ,
3843 } ) ,
3944 )
@@ -51,12 +56,14 @@ export const FilterStates = {
5156type FiltersProps = {
5257 categories : FilterCategoryConfig [ ]
5358 filterState : Record < string , string [ ] >
59+ enabledOptions : Record < string , Set < string > >
5460 onFilterChange : ( category : string , newSelectedOptions : string [ ] ) => void
5561}
5662
5763export function Filters ( {
5864 categories,
5965 filterState,
66+ enabledOptions,
6067 onFilterChange,
6168} : FiltersProps ) {
6269 return (
@@ -66,6 +73,7 @@ export function Filters({
6673 key = { category . property }
6774 label = { category . label }
6875 options = { category . options }
76+ enabledOptions = { enabledOptions [ category . property ] }
6977 value = { filterState [ category . property ] || [ ] }
7078 onChange = { newSelectedOptions => {
7179 onFilterChange ( category . property , newSelectedOptions )
@@ -109,6 +117,7 @@ export function ResetFiltersButton({
109117interface FiltersComboboxProps {
110118 label : string
111119 options : string [ ]
120+ enabledOptions : Set < string >
112121 value : string [ ]
113122 onChange : ( newSelectedOptions : string [ ] ) => void
114123 placeholder : string
@@ -117,6 +126,7 @@ interface FiltersComboboxProps {
117126function FiltersCombobox ( {
118127 label,
119128 options,
129+ enabledOptions,
120130 value,
121131 onChange,
122132 placeholder,
@@ -182,7 +192,11 @@ function FiltersCombobox({
182192 ) }
183193 >
184194 { filteredOptions . map ( option => (
185- < ComboboxOption key = { option } value = { option } >
195+ < ComboboxOption
196+ key = { option }
197+ value = { option }
198+ disabled = { ! enabledOptions . has ( option ) }
199+ >
186200 { ( { active, selected } ) => (
187201 < FilterComboboxOption
188202 active = { active }
@@ -248,6 +262,7 @@ function FilterComboboxOption({
248262 className = { clsx (
249263 "typography-body-sm relative flex cursor-default select-none items-center p-1 font-sans" ,
250264 active && "bg-neu-100 dark:bg-neu-50" ,
265+ "[[data-disabled]_&]:line-through [[data-disabled]_&]:opacity-40" ,
251266 ) }
252267 >
253268 < CheckboxIcon
0 commit comments