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')};
|
2024-05-12 21:42:33 +00:00
|
|
|
padding: ${dt('tree.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-12 21:42:33 +00:00
|
|
|
.p-tree-root-children,
|
|
|
|
.p-tree-node-children {
|
|
|
|
display: flex;
|
2024-05-01 08:26:48 +00:00
|
|
|
list-style-type: none;
|
2024-05-12 21:42:33 +00:00
|
|
|
flex-direction: column;
|
|
|
|
margin: 0;
|
|
|
|
gap: ${dt('tree.gap')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-12 21:42:33 +00:00
|
|
|
.p-tree-root-children {
|
|
|
|
padding: ${dt('tree.gap')} 0 0 0;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-12 21:42:33 +00:00
|
|
|
.p-tree-node-children {
|
|
|
|
padding: ${dt('tree.gap')} 0 0 ${dt('tree.indent')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-12 21:42:33 +00:00
|
|
|
.p-tree-node {
|
|
|
|
padding: 0;
|
|
|
|
outline: 0 none;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content {
|
2024-05-12 21:42:33 +00:00
|
|
|
border-radius: ${dt('tree.node.border.radius')};
|
|
|
|
padding: ${dt('tree.node.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
outline-color: transparent;
|
|
|
|
color: ${dt('tree.node.color')};
|
2024-05-12 21:42:33 +00:00
|
|
|
gap: ${dt('tree.node.gap')};
|
|
|
|
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node:focus-visible > .p-tree-node-content {
|
2024-05-12 21:42:33 +00:00
|
|
|
box-shadow: ${dt('tree.node.focus.ring.shadow')};
|
|
|
|
outline: ${dt('tree.node.focus.ring.width')} ${dt('tree.node.focus.ring.style')} ${dt('tree.node.focus.ring.color')};
|
|
|
|
outline-offset: ${dt('tree.node.focus.ring.offset')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.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-icon {
|
|
|
|
color: ${dt('tree.node.icon.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selected {
|
2024-05-12 21:42:33 +00:00
|
|
|
background: ${dt('tree.node.selected.background')};
|
|
|
|
color: ${dt('tree.node.selected.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-node-content.p-tree-node-selected .p-tree-node-toggle-button {
|
|
|
|
color: inherit;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.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;
|
2024-05-12 21:42:33 +00:00
|
|
|
width: ${dt('tree.node.toggle.button.size')};
|
|
|
|
height: ${dt('tree.node.toggle.button.size')};
|
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;
|
2024-05-12 21:42:33 +00:00
|
|
|
border-radius: ${dt('tree.node.toggle.button.border.radius')};
|
|
|
|
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')};
|
2024-05-01 08:26:48 +00:00
|
|
|
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:hover {
|
2024-05-12 21:42:33 +00:00
|
|
|
background: ${dt('tree.node.toggle.button.selected.hover.background')};
|
|
|
|
color: ${dt('tree.node.toggle.button.selected.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.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 {
|
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')};
|
|
|
|
}
|
|
|
|
|
2024-05-12 21:42:33 +00:00
|
|
|
.p-tree-node-content.p-tree-node-selected .p-tree-node-icon {
|
|
|
|
color: ${dt('tree.node.icon.selected.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-filter-input {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-loading {
|
|
|
|
position: relative;
|
2024-05-12 21:42:33 +00:00
|
|
|
height: 100%;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-tree-loading-icon {
|
2024-05-12 21:42:33 +00:00
|
|
|
font-size: ${dt('tree.loading.icon.size')};
|
|
|
|
width: ${dt('tree.loading.icon.size')};
|
|
|
|
height: ${dt('tree.loading.icon.size')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
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-13 14:02:20 +00:00
|
|
|
mask: 'p-tree-mask p-overlay-mask',
|
2023-10-02 10:46:09 +00:00
|
|
|
loadingIcon: 'p-tree-loading-icon',
|
2024-05-06 15:23:01 +00:00
|
|
|
pcFilterInput: 'p-tree-filter-input',
|
2024-05-03 11:46:02 +00:00
|
|
|
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
|
|
|
|
});
|