aria-autocomplete
Version:
Accessible, extensible, JavaScript autocomplete with multi-select
261 lines (260 loc) • 6.77 kB
CSS
.aria-autocomplete__wrapper {
position: relative;
font-size: 16px;
}
.aria-autocomplete--hide {
display: none ;
}
.aria-autocomplete__sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
.aria-autocomplete__input {
border: 1px solid #606060;
width: 100%;
min-height: 44px;
padding: 6px 10px;
border-radius: 2px;
box-sizing: border-box;
font-family: inherit;
font-size: 14px;
}
.aria-autocomplete__input--disabled {
background-color: #ebebeb;
cursor: not-allowed;
}
.aria-autocomplete__show-all {
position: absolute;
top: 0;
right: 0;
width: 44px;
height: 44px;
border: 1px solid #606060;
background-repeat: no-repeat;
background-position: center center;
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg width='17' height='10' viewBox='0 0 17 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.023L8.488 8 16 1' stroke-width='1' stroke='%23434143' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
box-sizing: border-box;
}
.aria-autocomplete__show-all--disabled {
background-color: #ebebeb;
cursor: not-allowed;
}
.aria-autocomplete__list {
list-style: none;
position: absolute;
top: 48px;
z-index: 99999;
left: 0;
margin: 0;
padding: 3px 0 ;
height: auto;
min-height: 0;
max-height: 304px;
overflow-y: auto;
overflow-x: hidden;
width: 100%;
background: #fff;
border: 1px solid #606060;
border-radius: 2px;
font-size: 1em;
box-sizing: border-box;
box-shadow: none;
}
.aria-autocomplete__list--has-results[aria-label]:before {
content: attr(aria-label) ;
position: absolute;
top: 0;
left: 0;
width: 100%;
padding: 3px 10px 0;
font-size: 13px;
text-align: right;
opacity: 0.5;
box-sizing: border-box;
}
@media reader, speech, aural {
.aria-autocomplete__list--has-results[aria-label]:before {
display: none;
}
}
.aria-autocomplete__list--has-results[aria-label] li:first-child {
margin-top: 20px;
}
.aria-autocomplete__option {
display: block;
color: #434143;
text-decoration: none;
font-weight: normal;
list-style: none;
cursor: pointer;
padding: 7px 10px;
word-break: break-word;
}
.aria-autocomplete__option:focus {
border: none;
outline: none;
box-shadow: none;
}
.aria-autocomplete__option:hover,
.aria-autocomplete__option--focused {
background: #f3f3f3;
color: #000;
border: none;
margin: 0;
font-weight: normal;
text-decoration: underline;
cursor: pointer;
}
.aria-autocomplete__option:hover[aria-disabled='true'],
.aria-autocomplete__option--focused[aria-disabled='true'] {
background: #f5f5f5;
}
.aria-autocomplete__option--no-results,
.aria-autocomplete__option[aria-disabled='true'] {
opacity: 0.65 ;
color: #434143 ;
cursor: not-allowed ;
text-decoration: none ;
}
.aria-autocomplete__option--no-results {
margin-top: 0 ;
background: transparent ;
}
.aria-autocomplete__selected {
position: relative;
display: inline-flex;
align-items: center;
background: #606060;
border: 1px solid #606060;
padding: 0 28px 0 10px;
margin: 2px 4px 2px 0;
font-size: 13px;
color: #f3f3f3;
border-radius: 20px;
word-break: break-word;
cursor: pointer;
}
.aria-autocomplete__selected--disabled {
opacity: 0.7;
}
.aria-autocomplete__selected:hover,
.aria-autocomplete__selected:focus {
background: #474747;
color: #fff;
}
.aria-autocomplete__selected:after {
content: '';
position: absolute;
top: 50%;
right: 5px;
width: 20px;
height: 20px;
background-repeat: no-repeat;
background-position: center center;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='10' height='10' viewBox='0 0 10 10' version='1.1'%3E%3Cg id='surface1'%3E%3Cpath d='M 0.234375 10 L 5 5.21875 L 9.765625 10 L 9.988281 9.78125 L 5.21875 5 L 9.988281 0.21875 L 9.765625 0 L 5 4.78125 L 0.234375 0 L 0.0117188 0.21875 L 4.78125 5 L 0.0117188 9.78125 Z M 0.234375 10 ' style='stroke:%23ffffff;fill-rule:nonzero;fill:%23ffffff;fill-opacity:1;'/%3E%3C/g%3E%3C/svg%3E");
transform: translateY(-50%);
}
@media speech {
.aria-autocomplete__selected:after {
display: none;
}
}
.aria-autocomplete__selected--delete-all {
border-color: #db0000;
background: #db0000;
color: #fff;
}
.aria-autocomplete__selected--delete-all:hover,
.aria-autocomplete__selected--delete-all:focus {
background: #a80000;
}
.aria-autocomplete__wrapper--multiple .aria-autocomplete__input {
margin-bottom: 5px;
}
.aria-autocomplete__wrapper--show-all,
.aria-autocomplete__wrapper--autogrow.aria-autocomplete__wrapper--multiple.aria-autocomplete__wrapper--show-all {
padding-right: 43px;
}
.aria-autocomplete__wrapper--loading:after {
content: '';
position: absolute;
top: 0;
right: 0;
width: 24px;
height: 24px;
margin: 10px;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.25);
border: 2px solid #606060;
border-color: #606060 transparent #606060 transparent;
box-sizing: border-box;
animation: lds-dual-ring 1.2s linear infinite;
}
.aria-autocomplete__wrapper--loading .aria-autocomplete__show-all {
background-image: none;
}
.aria-autocomplete__wrapper--loading.aria-autocomplete__wrapper--autogrow:after {
top: 50%;
margin-top: -12px;
}
.aria-autocomplete__wrapper--autogrow {
display: flex;
flex-wrap: wrap;
align-items: center;
border: 1px solid #606060;
width: 100%;
min-height: 44px;
padding: 6px 10px;
border-radius: 2px;
box-sizing: border-box;
}
.aria-autocomplete__wrapper--autogrow.aria-autocomplete__wrapper--disabled {
background-color: #ebebeb;
cursor: not-allowed;
}
.aria-autocomplete__wrapper--autogrow .aria-autocomplete__show-all {
order: 3;
height: 100%;
border-top: none;
border-right: none;
border-bottom: none;
}
.aria-autocomplete__wrapper--autogrow .aria-autocomplete__input {
max-width: 100% ;
max-height: none ;
min-height: 0 ;
padding: 0 ;
margin: 0 ;
line-height: inherit ;
text-indent: 0 ;
background: none ;
border: 0 none ;
outline: 0 ;
box-shadow: none ;
-webkit-user-select: auto ;
height: 26px;
width: 1px;
order: 2;
}
.aria-autocomplete__wrapper--autogrow .aria-autocomplete__list {
width: calc(100% + 2px);
top: calc(100% + 4px);
left: -1px;
}
.aria-autocomplete__wrapper--autogrow .aria-autocomplete__selected {
order: 1;
}
@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}