2023-10-02 10:46:09 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
const theme = ({ dt }) => `
|
|
|
|
.p-autocomplete {
|
|
|
|
display: inline-flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-loader {
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
margin-top: -0.5rem;
|
2024-05-06 22:54:05 +00:00
|
|
|
right: ${dt('autocomplete.padding.x')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete:has(.p-autocomplete-dropdown) .p-autocomplete-loader {
|
2024-05-06 22:54:05 +00:00
|
|
|
right: calc(${dt('autocomplete.dropdown.width')} + ${dt('autocomplete.padding.x')});
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete:has(.p-autocomplete-dropdown) .p-autocomplete-input {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
width: 1%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete:has(.p-autocomplete-dropdown) .p-autocomplete-input,
|
|
|
|
.p-autocomplete:has(.p-autocomplete-dropdown) .p-autocomplete-input-multiple {
|
|
|
|
border-top-right-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-dropdown {
|
|
|
|
cursor: pointer;
|
|
|
|
display: inline-flex;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
width: ${dt('autocomplete.dropdown.width')};
|
2024-05-08 22:52:39 +00:00
|
|
|
border-top-right-radius: ${dt('autocomplete.dropdown.border.radius')};
|
|
|
|
border-bottom-right-radius: ${dt('autocomplete.dropdown.border.radius')};
|
2024-05-01 08:26:48 +00:00
|
|
|
background: ${dt('autocomplete.dropdown.background')};
|
|
|
|
border: 1px solid ${dt('autocomplete.dropdown.border.color')};
|
|
|
|
border-left: 0 none;
|
2024-05-05 15:33:04 +00:00
|
|
|
color: ${dt('autocomplete.dropdown.color')};
|
2024-05-26 21:38:39 +00:00
|
|
|
transition: background ${dt('autocomplete.transition.duration')}, color ${dt('autocomplete.transition.duration')}, border-color ${dt('autocomplete.transition.duration')}, outline-color ${dt('autocomplete.transition.duration')}, box-shadow ${dt(
|
|
|
|
'autocomplete.transition.duration'
|
|
|
|
)};
|
2024-05-01 08:26:48 +00:00
|
|
|
outline-color: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-dropdown:not(:disabled):hover {
|
|
|
|
background: ${dt('autocomplete.dropdown.hover.background')};
|
|
|
|
border-color: ${dt('autocomplete.dropdown.hover.border.color')};
|
2024-05-05 15:33:04 +00:00
|
|
|
color: ${dt('autocomplete.dropdown.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-dropdown:not(:disabled):active {
|
|
|
|
background: ${dt('autocomplete.dropdown.active.background')};
|
|
|
|
border-color: ${dt('autocomplete.dropdown.active.border.color')};
|
2024-05-05 15:33:04 +00:00
|
|
|
color: ${dt('autocomplete.dropdown.active.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-dropdown:focus-visible {
|
2024-05-08 22:52:39 +00:00
|
|
|
box-shadow: ${dt('autocomplete.dropdown.focus.ring.shadow')};
|
|
|
|
outline: ${dt('autocomplete.dropdown.focus.ring.width')} ${dt('autocomplete.dropdown.focus.ring.style')} ${dt('autocomplete.dropdown.focus.ring.color')};
|
|
|
|
outline-offset: ${dt('autocomplete.dropdown.focus.ring.offset')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete .p-autocomplete-overlay {
|
|
|
|
min-width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-overlay {
|
|
|
|
position: absolute;
|
|
|
|
overflow: auto;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
background: ${dt('autocomplete.overlay.background')};
|
|
|
|
color: ${dt('autocomplete.overlay.color')};
|
|
|
|
border: 1px solid ${dt('autocomplete.overlay.border.color')};
|
2024-05-07 09:53:26 +00:00
|
|
|
border-radius: ${dt('autocomplete.overlay.border.radius')};
|
2024-05-06 22:54:05 +00:00
|
|
|
box-shadow: ${dt('autocomplete.overlay.shadow')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-list {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
list-style-type: none;
|
2024-05-07 09:05:24 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: ${dt('autocomplete.list.gap')};
|
2024-05-06 22:54:05 +00:00
|
|
|
padding: ${dt('autocomplete.list.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-option {
|
|
|
|
cursor: pointer;
|
|
|
|
white-space: nowrap;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
2024-05-30 08:27:03 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2024-05-06 22:54:05 +00:00
|
|
|
padding: ${dt('autocomplete.option.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
border: 0 none;
|
2024-05-05 15:33:04 +00:00
|
|
|
color: ${dt('autocomplete.option.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
background: transparent;
|
2024-05-25 08:18:55 +00:00
|
|
|
transition: background ${dt('autocomplete.transition.duration')}, color ${dt('autocomplete.transition.duration')}, border-color ${dt('autocomplete.transition.duration')};
|
2024-05-06 22:54:05 +00:00
|
|
|
border-radius: ${dt('autocomplete.option.border.radius')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-option:not(.p-autocomplete-option-selected):not(.p-disabled).p-focus {
|
2024-05-05 15:33:04 +00:00
|
|
|
background: ${dt('autocomplete.option.focus.background')};
|
|
|
|
color: ${dt('autocomplete.option.focus.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-option-selected {
|
2024-05-05 15:33:04 +00:00
|
|
|
background: ${dt('autocomplete.option.selected.background')};
|
|
|
|
color: ${dt('autocomplete.option.selected.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-option-selected.p-focus {
|
2024-05-05 15:33:04 +00:00
|
|
|
background: ${dt('autocomplete.option.selected.focus.background')};
|
|
|
|
color: ${dt('autocomplete.option.selected.focus.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-option-group {
|
|
|
|
margin: 0;
|
2024-05-06 22:54:05 +00:00
|
|
|
padding: ${dt('autocomplete.option.group.padding')};
|
2024-05-05 15:33:04 +00:00
|
|
|
color: ${dt('autocomplete.option.group.color')};
|
|
|
|
background: ${dt('autocomplete.option.group.background')};
|
2024-05-06 22:54:05 +00:00
|
|
|
font-weight: ${dt('autocomplete.option.group.font.weight')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-input-multiple {
|
|
|
|
margin: 0;
|
|
|
|
list-style-type: none;
|
|
|
|
cursor: text;
|
|
|
|
overflow: hidden;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-wrap: wrap;
|
2024-05-06 22:54:05 +00:00
|
|
|
padding: calc(${dt('autocomplete.padding.y')} / 2) ${dt('autocomplete.padding.x')};
|
|
|
|
gap: calc(${dt('autocomplete.padding.y')} / 2);
|
|
|
|
color: ${dt('autocomplete.color')};
|
|
|
|
background: ${dt('autocomplete.background')};
|
|
|
|
border: 1px solid ${dt('autocomplete.border.color')};
|
|
|
|
border-radius: ${dt('autocomplete.border.radius')};
|
2024-05-01 08:26:48 +00:00
|
|
|
width: 100%;
|
2024-05-26 21:38:39 +00:00
|
|
|
transition: background ${dt('autocomplete.transition.duration')}, color ${dt('autocomplete.transition.duration')}, border-color ${dt('autocomplete.transition.duration')}, outline-color ${dt('autocomplete.transition.duration')}, box-shadow ${dt(
|
|
|
|
'autocomplete.transition.duration'
|
|
|
|
)};
|
2024-05-01 08:26:48 +00:00
|
|
|
outline-color: transparent;
|
2024-05-06 22:54:05 +00:00
|
|
|
box-shadow: ${dt('autocomplete.shadow')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete:not(.p-disabled):hover .p-autocomplete-input-multiple {
|
2024-05-06 22:54:05 +00:00
|
|
|
border-color: ${dt('autocomplete.hover.border.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete:not(.p-disabled).p-focus .p-autocomplete-input-multiple {
|
2024-05-06 22:54:05 +00:00
|
|
|
border-color: ${dt('autocomplete.focus.border.color')};
|
2024-05-07 06:51:53 +00:00
|
|
|
box-shadow: ${dt('autocomplete.focus.ring.shadow')};
|
|
|
|
outline: ${dt('autocomplete.focus.ring.width')} ${dt('autocomplete.focus.ring.style')} ${dt('autocomplete.focus.ring.color')};
|
|
|
|
outline-offset: ${dt('autocomplete.focus.ring.offset')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete.p-invalid .p-autocomplete-input-multiple {
|
2024-05-06 22:54:05 +00:00
|
|
|
border-color: ${dt('autocomplete.invalid.border.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-variant-filled.p-autocomplete-input-multiple {
|
2024-05-06 22:54:05 +00:00
|
|
|
background: ${dt('autocomplete.filled.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete:not(.p-disabled).p-focus .p-variant-filled.p-autocomplete-input-multiple {
|
2024-05-06 22:54:05 +00:00
|
|
|
background: ${dt('autocomplete.filled.focus.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete.p-disabled .p-autocomplete-input-multiple {
|
|
|
|
opacity: 1;
|
2024-05-06 22:54:05 +00:00
|
|
|
background: ${dt('autocomplete.disabled.background')};
|
|
|
|
color: ${dt('autocomplete.disabled.color')};
|
|
|
|
}
|
|
|
|
|
2024-05-15 08:48:30 +00:00
|
|
|
.p-autocomplete-chip.p-chip {
|
2024-05-06 22:54:05 +00:00
|
|
|
padding-top: calc(${dt('autocomplete.padding.y')} / 2);
|
|
|
|
padding-bottom: calc(${dt('autocomplete.padding.y')} / 2);
|
2024-05-07 09:48:55 +00:00
|
|
|
border-radius: ${dt('autocomplete.chip.border.radius')};
|
2024-05-06 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
2024-05-15 08:48:30 +00:00
|
|
|
.p-autocomplete-input-multiple:has(.p-autocomplete-chip) {
|
2024-05-06 22:54:05 +00:00
|
|
|
padding-left: calc(${dt('autocomplete.padding.y')} / 2);
|
|
|
|
padding-right: calc(${dt('autocomplete.padding.y')} / 2);
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-15 08:48:30 +00:00
|
|
|
.p-autocomplete-chip-item.p-focus .p-autocomplete-chip {
|
|
|
|
background: ${dt('inputchips.chip.focus.background')};
|
|
|
|
color: ${dt('inputchips.chip.focus.color')};
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
.p-autocomplete-input-chip {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
display: inline-flex;
|
2024-05-06 22:54:05 +00:00
|
|
|
padding-top: calc(${dt('autocomplete.padding.y')} / 2);
|
|
|
|
padding-bottom: calc(${dt('autocomplete.padding.y')} / 2);
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-input-chip input {
|
|
|
|
border: 0 none;
|
|
|
|
outline: 0 none;
|
|
|
|
background: transparent;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
box-shadow: none;
|
|
|
|
border-radius: 0;
|
|
|
|
width: 100%;
|
|
|
|
font-family: inherit;
|
|
|
|
font-feature-settings: inherit;
|
|
|
|
font-size: 1rem;
|
|
|
|
color: inherit;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-autocomplete-input-chip input::placeholder {
|
2024-05-06 22:54:05 +00:00
|
|
|
color: ${dt('autocomplete.placeholder.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-08 10:04:04 +00:00
|
|
|
.p-autocomplete-empty-message {
|
|
|
|
padding: ${dt('autocomplete.empty.message.padding')};
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
.p-fluid .p-autocomplete {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-fluid .p-autocomplete:has(.p-autocomplete-dropdown) .p-autocomplete-input {
|
|
|
|
width: 1%;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-10-02 10:46:09 +00:00
|
|
|
const inlineStyles = {
|
|
|
|
root: { position: 'relative' }
|
|
|
|
};
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
root: ({ instance, props }) => [
|
|
|
|
'p-autocomplete p-component p-inputwrapper',
|
|
|
|
{
|
|
|
|
'p-disabled': props.disabled,
|
2024-01-30 11:27:56 +00:00
|
|
|
'p-invalid': props.invalid,
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-focus': instance.focused,
|
|
|
|
'p-inputwrapper-filled': props.modelValue || ObjectUtils.isNotEmpty(instance.inputValue),
|
|
|
|
'p-inputwrapper-focus': instance.focused,
|
2024-04-06 20:52:27 +00:00
|
|
|
'p-autocomplete-open': instance.overlayVisible
|
2024-02-02 11:46:26 +00:00
|
|
|
}
|
|
|
|
],
|
2024-05-06 13:11:02 +00:00
|
|
|
pcInput: 'p-autocomplete-input',
|
2024-05-03 11:46:02 +00:00
|
|
|
inputMultiple: ({ props, instance }) => [
|
2024-04-08 10:49:53 +00:00
|
|
|
'p-autocomplete-input-multiple',
|
2024-02-02 11:46:26 +00:00
|
|
|
{
|
2024-05-27 10:28:07 +00:00
|
|
|
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
|
2024-02-02 11:46:26 +00:00
|
|
|
}
|
|
|
|
],
|
2024-05-15 07:35:36 +00:00
|
|
|
chipItem: ({ instance, i }) => [
|
|
|
|
'p-autocomplete-chip-item',
|
2024-03-18 10:01:24 +00:00
|
|
|
{
|
|
|
|
'p-focus': instance.focusedMultipleOptionIndex === i
|
|
|
|
}
|
|
|
|
],
|
2024-05-15 07:35:36 +00:00
|
|
|
pcChip: 'p-autocomplete-chip',
|
2024-05-03 11:46:02 +00:00
|
|
|
chipIcon: 'p-autocomplete-chip-icon',
|
|
|
|
inputChip: 'p-autocomplete-input-chip',
|
2024-05-06 13:11:02 +00:00
|
|
|
loader: 'p-autocomplete-loader',
|
|
|
|
dropdown: 'p-autocomplete-dropdown',
|
2024-05-10 11:24:01 +00:00
|
|
|
overlay: 'p-autocomplete-overlay p-component',
|
2024-04-06 20:52:27 +00:00
|
|
|
list: 'p-autocomplete-list',
|
2024-05-06 13:11:02 +00:00
|
|
|
optionGroup: 'p-autocomplete-option-group',
|
|
|
|
option: ({ instance, option, i, getItemOptions }) => [
|
2024-04-07 09:40:54 +00:00
|
|
|
'p-autocomplete-option',
|
2023-10-02 10:46:09 +00:00
|
|
|
{
|
2024-04-07 09:40:54 +00:00
|
|
|
'p-autocomplete-option-selected': instance.isSelected(option),
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-focus': instance.focusedOptionIndex === instance.getOptionIndex(i, getItemOptions),
|
|
|
|
'p-disabled': instance.isOptionDisabled(option)
|
|
|
|
}
|
|
|
|
],
|
|
|
|
emptyMessage: 'p-autocomplete-empty-message'
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BaseStyle.extend({
|
|
|
|
name: 'autocomplete',
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-02 10:46:09 +00:00
|
|
|
classes,
|
|
|
|
inlineStyles
|
|
|
|
});
|