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-tree {
|
|
|
|
background: ${dt('tree.background')};
|
|
|
|
color: ${dt('tree.color')};
|
|
|
|
border-radius: ${dt('rounded.base')};
|
|
|
|
border: 0 none;
|
|
|
|
padding: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-root-children {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
list-style-type: none;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node {
|
|
|
|
padding: 0 0;
|
|
|
|
outline: 0 none;
|
|
|
|
margin: 2px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-root-children > .p-tree-node:first-child {
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-root-children > .p-tree-node:last-child {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content {
|
|
|
|
border-radius: ${dt('rounded.base')};
|
|
|
|
padding: 0.25rem 0.5rem;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
outline-color: transparent;
|
|
|
|
color: ${dt('tree.node.color')};
|
|
|
|
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}, outline-color ${dt('transition.duration')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node:focus-visible > .p-tree-node-content {
|
|
|
|
outline: 1px solid ${dt('focus.ring.color')};
|
|
|
|
outline-offset: -2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selected {
|
|
|
|
background: ${dt('highlight.background')};
|
|
|
|
color: ${dt('highlight.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-toggle-button {
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
flex-shrink: 0;
|
|
|
|
margin: 0 0.5rem 0 0;
|
|
|
|
width: 1.75rem;
|
|
|
|
height: 1.75rem;
|
2024-05-04 21:57:50 +00:00
|
|
|
color: ${dt('tree.node.toggle.button.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
border: 0 none;
|
|
|
|
background: transparent;
|
|
|
|
border-radius: 50%;
|
|
|
|
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')};
|
|
|
|
outline-color: transparent;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-toggle-button:enabled:hover {
|
2024-05-04 21:57:50 +00:00
|
|
|
background: ${dt('tree.node.toggle.button.hover.background')};
|
|
|
|
color: ${dt('tree.node.toggle.button.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selected .p-tree-node-toggle-button,
|
|
|
|
.p-tree-node-content.p-tree-node-selected .p-tree-node-toggle-icon {
|
|
|
|
color: inherit;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selected .p-tree-node-toggle-button:hover {
|
2024-05-04 21:57:50 +00:00
|
|
|
background: ${dt('tree.node.toggle.button.highlight.hover.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selectable:not(.p-tree-node-selected):hover {
|
|
|
|
background: ${dt('tree.node.hover.background')};
|
|
|
|
color: ${dt('tree.node.hover.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selectable:not(.p-tree-node-selected):hover .p-tree-node-toggle-button {
|
2024-05-04 21:57:50 +00:00
|
|
|
color: ${dt('tree.node.toggle.button.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selectable:not(.p-tree-node-selected):hover .p-tree-node-icon {
|
2024-05-04 21:57:50 +00:00
|
|
|
color: ${dt('tree.node.icon.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-children {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
list-style-type: none;
|
|
|
|
padding: 0 0 0 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-root {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-selectable {
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-leaf > .p-tree-node-content .p-tree-node-toggle-button {
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-icon {
|
|
|
|
margin-right: 0.5rem;
|
2024-05-04 21:57:50 +00:00
|
|
|
color: ${dt('tree.node.icon.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
transition: color ${dt('transition.duration')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content .p-checkbox {
|
|
|
|
margin-right: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-filter-input {
|
|
|
|
width: 100%;
|
|
|
|
padding-right: 1.75rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-filter-container {
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
margin-bottom: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-filter-icon {
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
margin-top: -0.5rem;
|
|
|
|
right: 0.75rem;
|
|
|
|
color: ${dt('tree.filter.icon.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-loading {
|
|
|
|
position: relative;
|
|
|
|
min-height: 4rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-loading-icon {
|
|
|
|
font-size: 2rem;
|
|
|
|
width: 2rem;
|
|
|
|
height: 2rem;
|
|
|
|
}
|
|
|
|
|
2024-05-03 11:46:02 +00:00
|
|
|
.p-tree .p-tree-mask {
|
2024-05-01 08:26:48 +00:00
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-flex-scrollable {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
height: 100%;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-flex-scrollable .p-tree-root {
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-10-02 10:46:09 +00:00
|
|
|
const classes = {
|
|
|
|
root: ({ props }) => [
|
|
|
|
'p-tree p-component',
|
|
|
|
{
|
|
|
|
'p-tree-selectable': props.selectionMode != null,
|
|
|
|
'p-tree-loading': props.loading,
|
|
|
|
'p-tree-flex-scrollable': props.scrollHeight === 'flex'
|
|
|
|
}
|
|
|
|
],
|
2024-05-03 11:46:02 +00:00
|
|
|
mask: 'p-tree-mask p-component-overlay',
|
2023-10-02 10:46:09 +00:00
|
|
|
loadingIcon: 'p-tree-loading-icon',
|
|
|
|
filterContainer: 'p-tree-filter-container',
|
2024-05-03 11:46:02 +00:00
|
|
|
filterInput: 'p-tree-filter-input',
|
|
|
|
filterIcon: 'p-tree-filter-icon',
|
|
|
|
wrapper: 'p-tree-root', //TODO: discuss
|
|
|
|
rootChildren: 'p-tree-root-children',
|
2024-04-25 22:47:09 +00:00
|
|
|
node: ({ instance }) => ['p-tree-node', { 'p-tree-node-leaf': instance.leaf }],
|
2024-05-03 11:46:02 +00:00
|
|
|
nodeContent: ({ instance }) => [
|
2024-04-25 22:47:09 +00:00
|
|
|
'p-tree-node-content',
|
2023-10-02 10:46:09 +00:00
|
|
|
instance.node.styleClass,
|
|
|
|
{
|
2024-04-25 22:47:09 +00:00
|
|
|
'p-tree-node-selectable': instance.selectable,
|
|
|
|
'p-tree-node-selected': instance.checkboxMode && instance.$parentInstance.highlightOnSelect ? instance.checked : instance.selected
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
],
|
2024-05-03 11:46:02 +00:00
|
|
|
nodeToggleButton: 'p-tree-node-toggle-button',
|
|
|
|
nodeToggleIcon: 'p-tree-node-toggle-icon',
|
|
|
|
nodeTogglerIcon: 'p-tree-node-toggler-icon', //TODO: discuss
|
2024-04-25 22:47:09 +00:00
|
|
|
nodeCheckbox: 'p-tree-node-checkbox',
|
|
|
|
nodeIcon: 'p-tree-node-icon',
|
2024-05-03 11:46:02 +00:00
|
|
|
nodeLabel: 'p-tree-node-label',
|
|
|
|
nodeChildren: 'p-tree-node-children'
|
2023-10-02 10:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default BaseStyle.extend({
|
|
|
|
name: 'tree',
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-02 10:46:09 +00:00
|
|
|
classes
|
|
|
|
});
|