2023-10-02 10:46:09 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
const theme = ({ dt }) => `
|
|
|
|
.p-listbox {
|
|
|
|
background: ${dt('listbox.background')};
|
|
|
|
color: ${dt('listbox.color')};
|
|
|
|
border: 1px solid ${dt('listbox.border.color')};
|
2024-05-07 14:29:18 +00:00
|
|
|
border-radius: ${dt('listbox.border.radius')};
|
|
|
|
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')}, outline-color ${dt('transition.duration')};
|
2024-05-01 08:26:48 +00:00
|
|
|
outline-color: transparent;
|
2024-05-07 14:29:18 +00:00
|
|
|
box-shadow: ${dt('listbox.shadow')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox.p-focus {
|
|
|
|
border-color: ${dt('listbox.focus.border.color')};
|
2024-05-07 14:29:18 +00:00
|
|
|
box-shadow: ${dt('listbox.focus.ring.shadow')};
|
|
|
|
outline: ${dt('listbox.focus.ring.width')} ${dt('listbox.focus.ring.style')} ${dt('listbox.focus.ring.color')};
|
|
|
|
outline-offset: ${dt('listbox.focus.ring.offset')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox.p-disabled {
|
|
|
|
opacity: 1;
|
|
|
|
background: ${dt('listbox.disabled.background')};
|
|
|
|
color: ${dt('listbox.disabled.color')};
|
|
|
|
}
|
|
|
|
|
2024-05-08 07:15:52 +00:00
|
|
|
.p-listbox.p-disabled .p-listbox-option {
|
|
|
|
color: ${dt('listbox.disabled.color')};
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
.p-listbox.p-invalid {
|
|
|
|
border-color: ${dt('listbox.invalid.border.color')};
|
|
|
|
}
|
|
|
|
|
2024-05-07 14:29:18 +00:00
|
|
|
.p-listbox-header {
|
2024-05-08 07:15:52 +00:00
|
|
|
padding: ${dt('listbox.list.header.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox-filter {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox-list-container {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox-list {
|
|
|
|
list-style-type: none;
|
|
|
|
margin: 0;
|
2024-05-07 14:29:18 +00:00
|
|
|
padding: ${dt('listbox.list.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
outline: 0 none;
|
2024-05-07 14:29:18 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: ${dt('listbox.list.gap')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox-option {
|
|
|
|
cursor: pointer;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
2024-05-07 14:29:18 +00:00
|
|
|
padding: ${dt('listbox.option.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
border: 0 none;
|
2024-05-07 14:29:18 +00:00
|
|
|
border-radius: ${dt('listbox.option.border.radius')};
|
2024-05-05 17:14:00 +00:00
|
|
|
color: ${dt('listbox.option.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')}, outline-color ${dt('transition.duration')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox .p-listbox-list .p-listbox-option.p-listbox-option-selected {
|
2024-05-05 17:14:00 +00:00
|
|
|
background: ${dt('listbox.option.selected.background')};
|
|
|
|
color: ${dt('listbox.option.selected.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox:not(.p-disabled) .p-listbox-option.p-listbox-option-selected.p-focus {
|
2024-05-05 17:14:00 +00:00
|
|
|
background: ${dt('listbox.option.selected.focus.background')};
|
|
|
|
color: ${dt('listbox.option.selected.focus.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox:not(.p-disabled) .p-listbox-option:not(.p-listbox-option-selected):not(.p-disabled).p-focus {
|
2024-05-05 17:14:00 +00:00
|
|
|
background: ${dt('listbox.option.focus.background')};
|
|
|
|
color: ${dt('listbox.option.focus.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox:not(.p-disabled) .p-listbox-option:not(.p-listbox-option-selected):not(.p-disabled):hover {
|
2024-05-05 17:14:00 +00:00
|
|
|
background: ${dt('listbox.option.focus.background')};
|
|
|
|
color: ${dt('listbox.option.focus.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox-option-group {
|
|
|
|
margin: 0;
|
2024-05-07 14:29:18 +00:00
|
|
|
padding: ${dt('listbox.option.group.padding')};
|
2024-05-05 17:14:00 +00:00
|
|
|
color: ${dt('listbox.option.group.color')};
|
|
|
|
background: ${dt('listbox.option.group.background')};
|
2024-05-07 14:29:18 +00:00
|
|
|
font-weight: ${dt('listbox.option.group.font.weight')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-listbox-empty-message {
|
2024-05-07 14:29:18 +00:00
|
|
|
padding: ${dt('listbox.option.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-10-02 10:46:09 +00:00
|
|
|
const classes = {
|
2024-03-18 10:02:20 +00:00
|
|
|
root: ({ props }) => [
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-listbox p-component',
|
|
|
|
{
|
2024-03-22 08:57:54 +00:00
|
|
|
'p-listbox-striped': props.stripedRows,
|
2024-01-30 11:27:56 +00:00
|
|
|
'p-disabled': props.disabled,
|
|
|
|
'p-invalid': props.invalid
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
header: 'p-listbox-header',
|
2024-05-06 15:23:01 +00:00
|
|
|
pcFilter: 'p-listbox-filter',
|
2024-05-03 20:53:04 +00:00
|
|
|
listContainer: 'p-listbox-list-container',
|
2023-10-02 10:46:09 +00:00
|
|
|
list: 'p-listbox-list',
|
2024-05-03 20:53:04 +00:00
|
|
|
optionGroup: 'p-listbox-option-group',
|
|
|
|
option: ({ instance, option, index, getItemOptions }) => [
|
2024-04-07 10:28:20 +00:00
|
|
|
'p-listbox-option',
|
2023-10-02 10:46:09 +00:00
|
|
|
{
|
2024-04-07 10:28:20 +00:00
|
|
|
'p-listbox-option-selected': instance.isSelected(option),
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-focus': instance.focusedOptionIndex === instance.getOptionIndex(index, getItemOptions),
|
|
|
|
'p-disabled': instance.isOptionDisabled(option)
|
|
|
|
}
|
|
|
|
],
|
|
|
|
emptyMessage: 'p-listbox-empty-message'
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BaseStyle.extend({
|
|
|
|
name: 'listbox',
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-02 10:46:09 +00:00
|
|
|
classes
|
|
|
|
});
|