@use "../abstract/base" as base;
@use "../abstract/functions" as f;
@use "../abstract/mixins" as m;
@use "../abstract/theme" as t;
@use "../abstract/variables" as v;
@use "../abstract/direction" as d;

$component: "#{base.$prefix}-list";
.#{$component} {
--#{base.$prefix}-list-item-offset: 0px;
position: relative;
overflow: auto;
color: t.color("on-surface");
padding-block: 8px;
&__content { display: flex; flex-direction: column; }
&__item {
position: relative;
display: flex;
align-items: center;
gap: 16px;
box-sizing: border-box;
min-width: 0;
min-height: f.density(56px, 36px);
padding: f.density(8px, 0px, 2px) 16px;
background: var(--#{base.$prefix}-list-item-container-color, t.color("surface"));
transform: translateY(var(--#{base.$prefix}-list-item-offset));
&--two-line { min-height: f.density(72px, 36px); }
&--three-line {
min-height: f.density(88px, 36px);
padding-block: f.density(12px, 0px, 2px);
align-items: flex-start;
}
}
&__text { min-width: 0; flex: 1; }
&__headline { @include m.typography("body-large"); color: t.color("on-surface"); }
&__overline { @include m.typography("label-small"); color: t.color("on-surface-variant"); }
&__supporting { @include m.typography("body-medium"); color: t.color("on-surface-variant"); }
&__headline, &__overline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
&__supporting {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
overflow-wrap: anywhere;
}
&__item--three-line &__supporting { -webkit-line-clamp: 2; }
&__item--three-line:has(.#{$component}__overline) &__supporting { -webkit-line-clamp: 1; }
&__leading, &__trailing {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
color: t.color("on-surface-variant");
&--icon { width: 24px; height: 24px; }
&--icon svg { width: 100%; height: 100%; }
&--avatar {
width: 40px; height: 40px; overflow: hidden; border-radius: 50%;
background: t.color("primary-container"); color: t.color("on-primary-container");
@include m.typography("title-medium");
}
&--image { width: 56px; height: 56px; overflow: hidden; border-radius: v.shape('small'); }
&--video { width: 100px; height: 56px; overflow: hidden; border-radius: v.shape('small'); }
&--avatar, &--image, &--video {
img, svg, video { width: 100%; height: 100%; object-fit: cover; }
}
&--text { @include m.typography("label-small"); white-space: nowrap; }
}
&__item--three-line &__leading--video { width: 114px; height: 64px; }
&__action {
font: inherit;
appearance: none;
position: absolute;
inset: 0;
width: 100%; height: 100%; padding: 0; margin: 0;
border: 0; border-radius: inherit;
background: transparent;
cursor: pointer;
&::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: t.color("on-surface"); opacity: 0; }
&::after {
content: "";
position: absolute;
left: 0;
right: 0;
top: 50%;
height: 48px;
transform: translateY(-50%);
}
&:hover:not(:disabled)::before { opacity: v.state("hover-state-layer-opacity"); }
&:active:not(:disabled)::before { opacity: v.state("pressed-state-layer-opacity"); }
&:focus-visible { outline: 2px solid t.color("secondary"); outline-offset: -2px; }
&:focus-visible::before { opacity: v.state("focus-state-layer-opacity"); }
&:disabled { cursor: default; }
}
&__item[role="option"] {
cursor: pointer;
&::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: t.color("on-surface"); opacity: 0; }
&:hover:not(.#{$component}__item--disabled)::before { opacity: v.state("hover-state-layer-opacity"); }
&:active:not(.#{$component}__item--disabled)::before { opacity: v.state("pressed-state-layer-opacity"); }
&:focus-visible { outline: 2px solid t.color("secondary"); outline-offset: -2px; }
&:focus-visible::before { opacity: v.state("focus-state-layer-opacity"); }
&.#{$component}__item--disabled { cursor: default; }
}
&__radio {
position: relative;
width: 20px; height: 20px;
box-sizing: border-box;
flex-shrink: 0;
border: 2px solid t.color("on-surface-variant");
border-radius: 50%;
transition: m.spring(border-color, fast-effects);
&::after {
content: "";
position: absolute;
top: 50%; left: 50%;
width: 10px; height: 10px;
border-radius: 50%;
background: t.color("primary");
transform: translate(-50%, -50%) scale(0);
transition: m.spring(transform, fast-spatial);
}
}
&__item--selected &__radio {
border-color: t.color("primary");
&::after { transform: translate(-50%, -50%) scale(1); }
}
&__item :is(button, input, select, textarea, a, [contenteditable="true"], [data-list-control]):not(.#{$component}__action) { position: relative; z-index: 1; }
&--segmented > &__content {
gap: var(--#{base.$prefix}-list-segmented-gap, 2px);
> .#{$component}__item { border-radius: var(--#{base.$prefix}-list-item-shape, v.shape('extra-small')); }
> .#{$component}__item:not(.#{$component}__item--selected) { background: var(--#{base.$prefix}-list-item-container-color, t.color("surface-container")); }
> .#{$component}__item:first-child,
> :not(.#{$component}__item) + .#{$component}__item {
@include d.corners(
$start-start: var(--#{base.$prefix}-list-item-shape-outer, v.shape('large')),
$start-end: var(--#{base.$prefix}-list-item-shape-outer, v.shape('large')),
$arm: false
);
}
> .#{$component}__item:last-child,
> .#{$component}__item:has(+ :not(.#{$component}__item)) {
@include d.corners(
$end-start: var(--#{base.$prefix}-list-item-shape-outer, v.shape('large')),
$end-end: var(--#{base.$prefix}-list-item-shape-outer, v.shape('large')),
$arm: false
);
}
> .#{$component}__item:hover:not(.#{$component}__item--disabled):not(.#{$component}__item--selected) {
border-radius: var(--#{base.$prefix}-list-item-shape-hover, v.shape('medium'));
}
> .#{$component}__item:has(.#{$component}__action:focus-visible):not(.#{$component}__item--disabled):not(.#{$component}__item--selected),
> .#{$component}__item[role="option"]:focus-visible:not(.#{$component}__item--disabled):not(.#{$component}__item--selected),
> .#{$component}__item:active:not(.#{$component}__item--disabled):not(.#{$component}__item--selected),
> .#{$component}__item.#{$component}__item--selected {
border-radius: var(--#{base.$prefix}-list-item-shape-active, v.shape('large'));
}
}
&__item--selected {
background: t.color("secondary-container");
.#{$component}__headline, .#{$component}__overline, .#{$component}__supporting, .#{$component}__leading, .#{$component}__trailing { color: t.color("on-secondary-container"); }
.#{$component}__action::before { background: t.color("on-secondary-container"); }
&[role="option"]::before { background: t.color("on-secondary-container"); }
}
&__item--disabled {
&.#{$component}__item--selected { background: t.alpha("on-surface", 0.38); }
.#{$component}__headline, .#{$component}__overline, .#{$component}__supporting, .#{$component}__leading, .#{$component}__trailing { color: t.color("on-surface"); }
.#{$component}__text, .#{$component}__leading, .#{$component}__trailing, .#{$component}__radio { opacity: 0.38; }
}
&__divider { height: 1px; min-height: 1px; background: t.color("outline-variant"); margin-block: 0; }
&__divider--inset { margin-inline-start: 72px; margin-inline-end: 16px; }
&__subheader { @include m.typography("label-large"); color: t.color("on-surface-variant"); padding: 16px 16px 8px; }
&__empty { @include m.typography("body-medium"); color: t.color("on-surface-variant"); padding: 16px; }
}
