matcha-components 20.143.0 → 20.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/matcha-components.mjs +29 -119
- package/fesm2022/matcha-components.mjs.map +1 -1
- package/index.d.ts +2 -15
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { EventEmitter, Output, HostBinding, Input, Component, ContentChildren, ElementRef, Renderer2, Inject, ViewEncapsulation, ChangeDetectionStrategy, HostListener, ContentChild, Directive, forwardRef, ViewChild, InjectionToken, inject, Injectable, TemplateRef, Optional, NgModule, createComponent, Pipe, PLATFORM_ID } from '@angular/core';
|
|
3
3
|
import { animation, style, animate, trigger, transition, useAnimation, state, query, stagger, animateChild, sequence, group } from '@angular/animations';
|
|
4
|
-
import { Subscription, Subject,
|
|
4
|
+
import { Subscription, Subject, BehaviorSubject, fromEvent, of } from 'rxjs';
|
|
5
5
|
import { debounceTime, takeUntil, filter, startWith, map, distinctUntilChanged } from 'rxjs/operators';
|
|
6
6
|
import * as i1 from '@angular/common';
|
|
7
7
|
import { DOCUMENT, CommonModule, isPlatformBrowser } from '@angular/common';
|
|
@@ -1888,9 +1888,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
|
|
|
1888
1888
|
}] } });
|
|
1889
1889
|
|
|
1890
1890
|
class MatchaMasonryComponent {
|
|
1891
|
-
constructor(
|
|
1892
|
-
this.elementRef = elementRef;
|
|
1893
|
-
this.cdr = cdr;
|
|
1891
|
+
constructor() {
|
|
1894
1892
|
this.colSize = null;
|
|
1895
1893
|
this.smColSize = null;
|
|
1896
1894
|
this.mdColSize = null;
|
|
@@ -1901,126 +1899,38 @@ class MatchaMasonryComponent {
|
|
|
1901
1899
|
this.gapMd = null;
|
|
1902
1900
|
this.gapLg = null;
|
|
1903
1901
|
this.gapXl = null;
|
|
1904
|
-
this.destroy$ = new Subject();
|
|
1905
|
-
this.originalItems = [];
|
|
1906
|
-
this.isDistributing = false;
|
|
1907
1902
|
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
// Capturar todos os filhos diretos (elementos projetados via ng-content)
|
|
1932
|
-
this.originalItems = Array.from(contentWrapper.children);
|
|
1933
|
-
}
|
|
1934
|
-
setupResizeObserver() {
|
|
1935
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
1936
|
-
if (!this.isDistributing) {
|
|
1937
|
-
this.distributeItems();
|
|
1938
|
-
}
|
|
1939
|
-
});
|
|
1940
|
-
// Observar os itens originais
|
|
1941
|
-
this.originalItems.forEach(item => {
|
|
1942
|
-
this.resizeObserver?.observe(item);
|
|
1943
|
-
});
|
|
1903
|
+
get classes() {
|
|
1904
|
+
const col = this.colSize ? `masonry-${this.colSize}` : '';
|
|
1905
|
+
const smCol = this.smColSize ? `masonry-sm-${this.smColSize}` : '';
|
|
1906
|
+
const mdCol = this.mdColSize ? `masonry-md-${this.mdColSize}` : '';
|
|
1907
|
+
const lgCol = this.lgColSize ? `masonry-lg-${this.lgColSize}` : '';
|
|
1908
|
+
const xlCol = this.xlColSize ? `masonry-xl-${this.xlColSize}` : '';
|
|
1909
|
+
const gap = this.gap ? `masonry-gap-${this.gap}` : '';
|
|
1910
|
+
const gapSm = this.gapSm ? `masonry-gap-sm-${this.gapSm}` : '';
|
|
1911
|
+
const gapMd = this.gapMd ? `masonry-gap-md-${this.gapMd}` : '';
|
|
1912
|
+
const gapLg = this.gapLg ? `masonry-gap-lg-${this.gapLg}` : '';
|
|
1913
|
+
const gapXl = this.gapXl ? `masonry-gap-xl-${this.gapXl}` : '';
|
|
1914
|
+
let activeClasses = '';
|
|
1915
|
+
activeClasses += col ? ` ${col}` : '';
|
|
1916
|
+
activeClasses += smCol ? ` ${smCol}` : '';
|
|
1917
|
+
activeClasses += mdCol ? ` ${mdCol}` : '';
|
|
1918
|
+
activeClasses += lgCol ? ` ${lgCol}` : '';
|
|
1919
|
+
activeClasses += xlCol ? ` ${xlCol}` : '';
|
|
1920
|
+
activeClasses += gap ? ` ${gap}` : '';
|
|
1921
|
+
activeClasses += gapSm ? ` ${gapSm}` : '';
|
|
1922
|
+
activeClasses += gapMd ? ` ${gapMd}` : '';
|
|
1923
|
+
activeClasses += gapLg ? ` ${gapLg}` : '';
|
|
1924
|
+
activeClasses += gapXl ? ` ${gapXl}` : '';
|
|
1925
|
+
return activeClasses;
|
|
1944
1926
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
return;
|
|
1948
|
-
this.isDistributing = true;
|
|
1949
|
-
const columnCount = this.getCurrentColumnCount();
|
|
1950
|
-
console.log('🔵 Masonry Debug - Column count:', columnCount);
|
|
1951
|
-
if (columnCount <= 0) {
|
|
1952
|
-
this.isDistributing = false;
|
|
1953
|
-
return;
|
|
1954
|
-
}
|
|
1955
|
-
const columnsContainer = this.elementRef.nativeElement.querySelector('.masonry-columns');
|
|
1956
|
-
if (!columnsContainer) {
|
|
1957
|
-
console.error('❌ Masonry Debug - .masonry-columns not found!');
|
|
1958
|
-
this.isDistributing = false;
|
|
1959
|
-
return;
|
|
1960
|
-
}
|
|
1961
|
-
console.log('🔵 Masonry Debug - Container width:', columnsContainer.offsetWidth);
|
|
1962
|
-
// Limpar colunas existentes
|
|
1963
|
-
columnsContainer.innerHTML = '';
|
|
1964
|
-
// Criar divs de coluna
|
|
1965
|
-
const columnDivs = [];
|
|
1966
|
-
const columnHeights = [];
|
|
1967
|
-
for (let i = 0; i < columnCount; i++) {
|
|
1968
|
-
const columnDiv = document.createElement('div');
|
|
1969
|
-
columnDiv.className = 'masonry-column';
|
|
1970
|
-
columnsContainer.appendChild(columnDiv);
|
|
1971
|
-
columnDivs.push(columnDiv);
|
|
1972
|
-
columnHeights.push(0);
|
|
1973
|
-
}
|
|
1974
|
-
console.log('🔵 Masonry Debug - Created columns:', columnCount);
|
|
1975
|
-
console.log('🔵 Masonry Debug - Items to distribute:', this.originalItems.length);
|
|
1976
|
-
// Distribuir itens MOVENDO os elementos reais (não clonando)
|
|
1977
|
-
this.originalItems.forEach((item, index) => {
|
|
1978
|
-
// Encontrar coluna com menor altura
|
|
1979
|
-
const minHeightIndex = columnHeights.indexOf(Math.min(...columnHeights));
|
|
1980
|
-
console.log(`🔵 Item ${index + 1} -> Column ${minHeightIndex + 1} (height: ${item.offsetHeight}px)`);
|
|
1981
|
-
// MOVER o elemento real para a coluna (preserva todos os bindings do Angular)
|
|
1982
|
-
const gapValue = this.getGapValue();
|
|
1983
|
-
if (gapValue > 0) {
|
|
1984
|
-
item.style.marginBottom = `${gapValue}px`;
|
|
1985
|
-
}
|
|
1986
|
-
// appendChild move o nó (não clona)
|
|
1987
|
-
columnDivs[minHeightIndex].appendChild(item);
|
|
1988
|
-
// Atualizar altura da coluna
|
|
1989
|
-
columnHeights[minHeightIndex] += item.offsetHeight + gapValue;
|
|
1990
|
-
});
|
|
1991
|
-
console.log('🔵 Masonry Debug - Final column heights:', columnHeights);
|
|
1992
|
-
// Log da largura de cada coluna criada
|
|
1993
|
-
columnDivs.forEach((col, i) => {
|
|
1994
|
-
console.log(`🔵 Column ${i + 1} width:`, col.offsetWidth, 'px');
|
|
1995
|
-
});
|
|
1996
|
-
this.isDistributing = false;
|
|
1997
|
-
}
|
|
1998
|
-
getCurrentColumnCount() {
|
|
1999
|
-
const width = window.innerWidth;
|
|
2000
|
-
// Breakpoints do Material/Angular
|
|
2001
|
-
if (width >= 1920 && this.xlColSize)
|
|
2002
|
-
return Number(this.xlColSize);
|
|
2003
|
-
if (width >= 1280 && this.lgColSize)
|
|
2004
|
-
return Number(this.lgColSize);
|
|
2005
|
-
if (width >= 960 && this.mdColSize)
|
|
2006
|
-
return Number(this.mdColSize);
|
|
2007
|
-
if (width >= 600 && this.smColSize)
|
|
2008
|
-
return Number(this.smColSize);
|
|
2009
|
-
if (this.colSize)
|
|
2010
|
-
return Number(this.colSize);
|
|
2011
|
-
return 1; // Fallback para 1 coluna
|
|
2012
|
-
}
|
|
2013
|
-
getGapValue() {
|
|
2014
|
-
const gapStr = this.gap?.toString() || '0';
|
|
2015
|
-
return parseInt(gapStr, 10);
|
|
2016
|
-
}
|
|
2017
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMasonryComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2018
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaMasonryComponent, isStandalone: false, selector: "matcha-masonry", inputs: { colSize: ["col", "colSize"], smColSize: ["col-sm", "smColSize"], mdColSize: ["col-md", "mdColSize"], lgColSize: ["col-lg", "lgColSize"], xlColSize: ["col-xl", "xlColSize"], gap: "gap", gapSm: ["gap-sm", "gapSm"], gapMd: ["gap-md", "gapMd"], gapLg: ["gap-lg", "gapLg"], gapXl: ["gap-xl", "gapXl"] }, ngImport: i0, template: "<div class=\"masonry-wrapper\">\n <!-- Container com conte\u00FAdo original (oculto) -->\n <div class=\"masonry-content-wrapper\">\n <ng-content></ng-content>\n </div>\n\n <!-- Container onde as colunas ser\u00E3o renderizadas -->\n <div class=\"masonry-columns\" [style.gap.px]=\"getGapValue()\"></div>\n</div>", styles: [".masonry-wrapper{width:100%;position:relative}.masonry-content-wrapper{position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none}.masonry-columns{display:flex;width:100%}.masonry-column{flex:1 1 0;min-width:0;max-width:100%;display:flex;flex-direction:column}\n"] }); }
|
|
1927
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMasonryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1928
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaMasonryComponent, isStandalone: false, selector: "matcha-masonry", inputs: { colSize: ["col", "colSize"], smColSize: ["col-sm", "smColSize"], mdColSize: ["col-md", "mdColSize"], lgColSize: ["col-lg", "lgColSize"], xlColSize: ["col-xl", "xlColSize"], gap: "gap", gapSm: ["gap-sm", "gapSm"], gapMd: ["gap-md", "gapMd"], gapLg: ["gap-lg", "gapLg"], gapXl: ["gap-xl", "gapXl"] }, ngImport: i0, template: "<div [class]=\"classes\">\n <ng-content></ng-content>\n</div>\n", styles: [""] }); }
|
|
2019
1929
|
}
|
|
2020
1930
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMasonryComponent, decorators: [{
|
|
2021
1931
|
type: Component,
|
|
2022
|
-
args: [{ selector: 'matcha-masonry', standalone: false, template: "<div class=\"
|
|
2023
|
-
}],
|
|
1932
|
+
args: [{ selector: 'matcha-masonry', standalone: false, template: "<div [class]=\"classes\">\n <ng-content></ng-content>\n</div>\n" }]
|
|
1933
|
+
}], propDecorators: { colSize: [{
|
|
2024
1934
|
type: Input,
|
|
2025
1935
|
args: ['col']
|
|
2026
1936
|
}], smColSize: [{
|