diff --git a/src/components/Segments.tsx b/src/components/Segments.tsx index 7917e75..8ecfec9 100644 --- a/src/components/Segments.tsx +++ b/src/components/Segments.tsx @@ -24,6 +24,7 @@ interface SegmentsProps { defaultValue?: Option['value']; direction?: 'horizontal' | 'vertical'; disabled?: boolean; + readonly?: boolean; onChange?: (value: Option['value'] | undefined) => void; } @@ -32,6 +33,7 @@ const Segments: Component = (props) => { { options: [], disabled: false, + readonly: false, direction: 'horizontal', }, props, @@ -69,7 +71,7 @@ const Segments: Component = (props) => { }); const handleSelect = (value: Option['value']) => { - if (mProps.disabled) { + if (mProps.disabled || mProps.readonly) { return; } setSelected(value); @@ -88,8 +90,9 @@ const Segments: Component = (props) => {
(optionRefs[index] = el)} aria-disabled={mProps.disabled} + aria-readonly={mProps.readonly} class={cx( - 'z-[5] cursor-pointer rounded-sm px-2 py-0.5', + 'z-[5] cursor-pointer rounded-sm px-2 py-0.5 aria-readonly:cursor-not-allowed', selected() === option().value ? 'not-aria-disabled:text-on-primary-surface aria-disabled:text-primary-disabled' : 'not-aria-disabled:text-on-surface aria-disabled:text-neutral-disabled hover:not-aria-disabled:text-primary-hover',