Files
prestashop-entity-selector/sources/scss/components/_chips.scss
myprestarocks 7d79273743 Add hierarchical tree view for category selection
Features:
- Tree view mode for categories with expand/collapse
- Product count badges with clickable preview popover
- Select parent with all children button
- Client-side tree filtering (refine search)
- Keyboard shortcuts: Ctrl+A (select all), Ctrl+D (clear)
- View mode switching between tree/list/columns
- Tree view as default for categories, respects user preference

Backend:
- Add previewCategoryProducts and previewCategoryPages AJAX handlers
- Support pagination and filtering in category previews

Styling:
- Consistent count-badge styling across tree and other views
- Loading and popover-open states for count badges

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:03:51 +01:00

658 lines
15 KiB
SCSS

/**
* Chips Component
* Entity chips, selection pills, tags
*/
@use '../variables' as *;
@use '../mixins' as *;
.target-conditions-trait,
.entity-selector-trait {
// Chips container wrapper with toolbar
.chips-wrapper {
display: flex;
flex-direction: column;
margin-top: $es-spacing-sm;
background: $es-slate-50;
border: 1px solid $es-border-color;
border-radius: $es-radius-md;
overflow: hidden;
}
// Chips toolbar - search and actions
.chips-toolbar {
display: none; // Hidden by default, shown via JS when chips exist
align-items: center;
gap: $es-spacing-sm;
padding: $es-spacing-sm $es-spacing-md;
background: $es-white;
border-bottom: 1px solid $es-border-color;
&.has-chips {
display: flex;
}
// Search icon
> i {
color: $es-text-muted;
font-size: 14px;
flex-shrink: 0;
}
}
.chips-search-input,
input.chips-search-input,
input.chips-search-input[type="text"] {
flex: 1 !important;
min-width: 80px !important;
max-width: none !important;
width: auto !important;
height: auto !important;
padding: 0 !important;
border: none !important;
border-bottom: 1px solid transparent !important;
border-radius: 0 !important;
background: transparent !important;
font-size: $es-font-size-sm !important;
color: $es-text-primary;
box-shadow: none !important;
transition: border-color $es-transition-fast;
&:focus {
outline: none !important;
border: none !important;
border-bottom: 1px solid $es-primary !important;
box-shadow: none !important;
}
&::placeholder {
color: $es-text-muted;
}
}
.chips-count {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.625rem;
background: $es-primary;
color: $es-white;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-semibold;
border-radius: $es-radius-full;
white-space: nowrap;
&.has-filter {
background: $es-cyan-500;
}
.count-filtered {
font-weight: $es-font-weight-bold;
}
.count-separator {
opacity: 0.7;
}
}
.chips-actions {
display: flex;
align-items: center;
gap: $es-spacing-xs;
margin-left: auto;
}
.btn-chips-clear {
@include button-reset;
display: flex;
align-items: center;
gap: 0.375rem;
padding: 0.375rem 0.75rem;
color: $es-white;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-semibold;
background: $es-danger;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: darken($es-danger, 8%);
}
i {
font-size: 11px;
}
}
// Chips container
.entity-chips {
display: flex;
flex-wrap: wrap;
gap: $es-spacing-xs;
padding: $es-spacing-md;
min-height: 40px;
max-height: 300px;
overflow-y: auto;
&:empty {
display: none;
}
}
// Load more button
.chips-load-more {
display: flex;
align-items: center;
justify-content: center;
padding: $es-spacing-sm $es-spacing-md;
background: $es-white;
border-top: 1px solid $es-border-color;
.btn-load-more {
@include button-reset;
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.5rem 1rem;
color: $es-white;
font-size: $es-font-size-sm;
font-weight: $es-font-weight-semibold;
background: $es-primary;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: $es-primary-hover;
}
i {
font-size: 12px;
}
}
}
// Individual chip
.entity-chip {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.5rem;
background: $es-slate-100;
color: $es-text-secondary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-slate-200;
}
// Chip with image
&.has-image {
padding-left: 0.25rem;
}
// Hidden by search filter or pagination
&.chip-filtered-out,
&.chip-paginated-out {
display: none;
}
}
.chip-image {
width: 20px;
height: 20px;
object-fit: cover;
border-radius: 50%;
flex-shrink: 0;
}
.chip-icon {
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: $es-text-muted;
flex-shrink: 0;
// Product/entity images inside chip
img {
width: 20px;
height: 20px;
object-fit: cover;
border-radius: $es-radius-sm;
}
}
.chip-text,
.chip-name {
// Show full name, no truncation
word-break: break-word;
}
.chip-remove {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
margin-left: 0.125rem;
color: $es-text-muted;
border-radius: 50%;
flex-shrink: 0;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
color: $es-danger;
}
i {
font-size: 10px;
}
}
// Chip variants
.entity-chip.chip-primary {
background: $es-primary-light;
color: $es-primary;
&:hover {
background: rgba($es-primary, 0.2);
}
}
.entity-chip.chip-success {
background: $es-success-light;
color: $es-success-dark;
&:hover {
background: rgba($es-success, 0.2);
}
}
.entity-chip.chip-danger {
background: $es-danger-light;
color: $es-danger;
&:hover {
background: rgba($es-danger, 0.2);
}
}
.entity-chip.chip-warning {
background: $es-warning-light;
color: darken($es-warning, 20%);
&:hover {
background: rgba($es-warning, 0.3);
}
}
// Chip loading state
.entity-chip.loading,
.entity-chip-loading {
opacity: 0.7;
.chip-remove {
display: none;
}
.chip-icon i {
animation: spin 0.6s linear infinite;
}
}
// Hidden chip (collapsed view)
.entity-chip.chip-hidden {
display: none;
}
// Chips expanded/collapsed states
.entity-chips.chips-collapsed,
.entity-chips.chips-expanded {
position: relative;
}
// Show more/less toggle
.chips-show-more-toggle {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
color: $es-primary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
cursor: pointer;
transition: color $es-transition-fast;
&:hover {
color: $es-primary-hover;
}
i {
font-size: 10px;
}
}
.chips-collapse-toggle,
.chips-expand-toggle {
// Specific variants inherit from .chips-show-more-toggle
}
// More chips indicator
.chips-more {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.25rem 0.5rem;
background: $es-slate-200;
color: $es-text-secondary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-semibold;
border-radius: $es-radius-full;
cursor: pointer;
transition: all $es-transition-fast;
&:hover {
background: $es-slate-300;
}
}
// Add chip button
.chip-add-btn {
@include button-reset;
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
background: transparent;
color: $es-primary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border: 1px dashed $es-primary;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-primary-light;
}
i {
font-size: 10px;
}
}
// Inline chips (compact mode)
.entity-chips.inline {
display: inline-flex;
padding: 0;
min-height: auto;
.entity-chip {
padding: 0.125rem 0.375rem;
font-size: 11px;
}
}
// Selected chips section in include/exclude
.selected-chips-container {
display: flex;
flex-direction: column;
gap: $es-spacing-xs;
}
.selected-chips-label {
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
color: $es-text-muted;
}
// Pattern chips (for name/reference patterns)
.entity-chip.chip-pattern {
background: #fef3c7;
color: #92400e;
font-family: monospace;
&:hover {
background: #fde68a;
}
.chip-icon {
color: #d97706;
}
}
// Range chips (price, quantity, etc.)
.entity-chip.chip-range,
.range-chip {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.5rem;
background: $es-cyan-50;
color: $es-cyan-600;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-cyan-100;
}
}
.range-chip-text {
font-family: monospace;
}
.btn-remove-range {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
color: $es-cyan-600;
border-radius: 50%;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
color: $es-danger;
}
i {
font-size: 10px;
}
}
// Multi-range chips container
.multi-range-chips {
display: flex;
flex-wrap: wrap;
gap: $es-spacing-xs;
margin-bottom: $es-spacing-xs;
&:empty {
display: none;
}
}
// Pattern chips container
.pattern-chips {
display: flex;
flex-wrap: wrap;
gap: $es-spacing-xs;
padding: $es-spacing-sm 0;
min-height: 32px;
&:empty::before {
content: attr(data-placeholder);
color: $es-text-muted;
font-size: $es-font-size-xs;
font-style: italic;
}
}
// Pattern tag
.pattern-tag {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
background: #fef3c7;
color: #92400e;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: #fde68a;
}
&.case-sensitive {
.case-icon {
color: $es-success;
font-weight: $es-font-weight-bold;
}
}
&.draft-tag {
background: $es-white;
border: 1px solid $es-border-color;
padding: 0;
flex: 1;
min-width: 150px;
&:hover {
background: $es-white;
}
.pattern-input {
flex: 1;
min-width: 100px;
padding: 0.375rem;
border: 0;
background: transparent;
font-size: $es-font-size-sm;
font-family: inherit;
&:focus {
outline: none;
}
&::placeholder {
color: $es-text-muted;
font-style: italic;
}
}
}
}
.pattern-tag-text {
font-family: monospace;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.btn-toggle-case {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
color: $es-text-muted;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
}
}
.case-icon {
font-size: 11px;
font-weight: $es-font-weight-semibold;
font-family: monospace;
}
.btn-remove-pattern {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
color: #d97706;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
color: $es-danger;
}
i {
font-size: 10px;
}
}
.btn-add-pattern {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
color: $es-primary;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: $es-primary-light;
}
i {
font-size: 12px;
}
}
// Pattern match count (in draft tag)
.pattern-match-count {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0 0.375rem;
color: $es-text-muted;
font-size: $es-font-size-xs;
cursor: pointer;
&.count-zero {
color: $es-warning;
}
&.count-found {
color: $es-success;
}
.count-value {
font-weight: $es-font-weight-semibold;
}
}
// Pattern input row
.pattern-input-row {
display: flex;
align-items: stretch;
gap: $es-spacing-xs;
}
}