@@ -24,6 +24,7 @@ export interface CheckSingleProps
2424 MayHaveClass ,
2525 MayHaveInnerClass ,
2626 MayHaveDisabled {
27+ disallowDeselection ?: boolean
2728 optionClass ?: string
2829}
2930
@@ -46,6 +47,7 @@ export function CheckSingle(p: CheckSingleProps) {
4647 getOptions = { p . getOptions }
4748 valueText = { p . valueText }
4849 variant = { p . variant }
50+ disallowDeselection = { p . disallowDeselection }
4951 optionClass = { p . optionClass }
5052 innerClass = { p . innerClass }
5153 />
@@ -60,6 +62,7 @@ interface OptionListProps
6062 MayHaveButtonVariant ,
6163 MayHaveDisabled ,
6264 MayHaveInnerClass {
65+ disallowDeselection ?: boolean
6366 optionClass ?: string
6467}
6568
@@ -74,6 +77,7 @@ function OptionList(p: OptionListProps) {
7477 valueText = { p . valueText }
7578 optionClass = { p . optionClass }
7679 variant = { p . variant }
80+ disallowDeselection = { p . disallowDeselection }
7781 disabled = { p . disabled }
7882 />
7983 ) }
@@ -95,6 +99,7 @@ interface CheckOptionProps extends MayHaveButtonVariant, MayHaveDisabled {
9599 option : string
96100 valueSignal : SignalObject < string >
97101 valueText ?: ( value : string ) => string
102+ disallowDeselection ?: boolean
98103 optionClass ?: string
99104}
100105
@@ -108,7 +113,7 @@ function CheckOption(p: CheckOptionProps) {
108113 aria-selected = { isSelected ( ) }
109114 icon = { isSelected ( ) ? mdiCheckboxMarkedCircle : mdiCheckboxBlankCircleOutline }
110115 // iconRight={isSelected() ? mdiCheckboxMarkedCircle : mdiCheckboxBlankCircleOutline}
111- onClick = { ( ) => toggleOption ( p ) }
116+ onClick = { ( ) => toggleOption ( p , p . disallowDeselection ) }
112117 variant = { p . variant ?? buttonVariant . filled }
113118 class = { classMerge ( "justify-start text-left" , p . optionClass ) }
114119 disabled = { p . disabled }
@@ -118,9 +123,9 @@ function CheckOption(p: CheckOptionProps) {
118123 )
119124}
120125
121- function toggleOption ( p : CheckOptionProps ) {
126+ function toggleOption ( p : CheckOptionProps , disallowDeselection ?: boolean ) {
122127 const isSelected = p . valueSignal . get ( ) === p . option
123- if ( isSelected ) {
128+ if ( isSelected && ! disallowDeselection ) {
124129 p . valueSignal . set ( "" )
125130 } else {
126131 p . valueSignal . set ( p . option )
0 commit comments